Hello, stranger
Please introduce yourself by entering your name in the box below
Client Side Code:
After our first examples, this should be pretty straight-forward by now. The server's response is eval'd and therefor executed.
$(document).ready(function(){
$('#helloBtn').click(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "test4.php",
cache: false,
data: "inputName="+$("#helloTxt").val(),
dataType: "text",
success: function(text){
eval(text);
$("#main > div > p:first").append("
This is what the server returned: "+text);
}
});
});
});
function updateName(name,isLong){
$('#helloTitle').html("Hello, "+name+"
");
var listDivId=+(isLong) ? '#longNames' : '#shortNames';
$(listDivId).append(name+"
");
}
Server Side Code: