How to return jQuery Ajax data to a string?
code like this:
var data = $.get("e/as/ajax-dialog.php?do=member", function(data) {
return data;
});
alert(data); == > [object]
[object] is not what I want
I want the ajax callback html code to data[string]..
Update
My idea is wrong
Put result processing in the success handler
In your example,
alert(data)will be executed immediately after http request made and long before response is received.More examples here:
http://api.jquery.com/jQuery.get/
On question update.
There’s an example of synchronous request in jquery docs
It’s also explained there why making synchronous requests is generally bad idea. So, use it on your own risk.