My problem is that i wanna use post data outside it’s function, example:
$(function() {
var s = 'something ';
$.post('ajax.php', {option: 'test'}, function(data) {
s += data; // data: 'hello world';
});
alert(s); // output: 'something ';
});
my expected result is ‘something hello world’.
how can i deal with this?
Thanks
Use
$.ajaxwithasync:false, I assume the data is coming ascontent-type:json/applicatione.g.