在Jquery Ajax中,是否可以将响应值作为相应的函数返回值
checkSucess = function() {
// Jquery Ajax with url,params and response
doPost('sucess.php',
'first=' + first,
function(response) {
});
return response;// 'response' here is the value of response如何返回函数的ajax响应值,从其他函数调用
发布于 2011-11-26 12:55:40
当它是异步的时候,你不能按你想要的方式去做
如果您确定请求不会持续很长时间,则将其设为async: false并查看
checkSucess = function() {
var result;
//make it synchronus
$.ajaxSetup({async:false});
doPost('sucess.php',
'first=' + first,
function(response) {
//get the response
result = response;
});
//make it asynchronus
$.ajaxSetup({async:true});
return result;
}https://stackoverflow.com/questions/8276283
复制相似问题