I am using this code to get response back from server. But I want that asynchronously as I need to show progress. When I use this code, I don’t get any messsage back from server (only getting alert as object). Here is my code. Any ideas?
var msg = $.ajax({
type: 'POST',
url: '../pages/registration.php',
async: true,
data: {
do: 'register'
},
beforeSend: function () {
$("#Progress").show();
},
success: function (data, status) {
$("#Progress").hide();
$("#AckMsg").html(data);
}
});
alert("aa" + msg);
As of jQuery 1.5, a XMLHttpRequest (jqXHR) object is returned by $.ajax(). This is the object you assign to your var msg, and later put in the alert. Hence you get “alert as object” as you describe it. If you want to alert what is returned by the server, do:
If this alerts data as empty or undefined. Check your ajax call URL.
I believe using a relative URL like this will make a ajax request to http://www.yoursite.com/../pages/registration.php for example. This is most likely not what you want to do.