IT-info

jQuery

jQuery POST (PHP)

test.html:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>The jQuery Example</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#driver").click(function(event){
        $.post("result.php", {name:"Zara"}, function(data){$("#stage").html(data);});
    });
});
</script>
</head>
<body>
<p>Click on the button to load result.html file</p>

<div id="stage" style="background-color:#CC0;">
STAGE
</div>

<input type="button" id="driver" value="Load Data">
</body>
</html>

result.php:

<?php
if($_REQUEST["name"]){
    $name = $_REQUEST["name"];
    echo "Welcome ".$name;
}
?>

jQuery AJAX (C#.NET)

test.html:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<script type="text/javascript" src="jquery-2.1.4.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    $("#posttxt").click(function(){
        var textToSave = $('textarea#note').val();
        var authorName = $('input#authorname').val();
        
        $.ajax({
            url: 'test.aspx',
            type: 'GET',
            dataType: 'html'
,             async: true,
            data: {'text': textToSave, 'author': authorName},
            success: function(data){$("#textbox").text(data);}
        });
    });
});
</script>
</head>
<body>
<div>
<p>
<label for="notearea">Note:</label><br>
<textarea id="note" name="notearea" cols=50 rows=5></textarea>
</p>

<p>
<label for="name">Written by:</label><br>
<input type="text" id="authorname" name="name">
</p>

<p><button id="posttxt">Submit</button></p>
</div>

<div id="textbox"></div>
</body>
</html>

result.aspx:

<%@ Page Language="C#" %>

<%
string noteText = Request.QueryString["text"];
string aName = Request.QueryString["author"];

Response.Write("Hallo " + aName + ". You wrote: " + noteText);
%>