get value ajax jquery code example
Example 1: jquery ajax get
$.ajax({
url: "www.site.com/page",
success: function(data){
$('#data').text(data);
},
error: function(){
alert("There was an error.");
}
});
Example 2: $.get jquery return value
function showGetResult( name )
{
var result = null;
var scriptUrl = "somefile.php?name=" + name;
$.ajax({
url: scriptUrl,
type: 'get',
dataType: 'html',
async: false,
success: function(data) {
result = data;
}
});
return result;
}