请看我的代码:
function ess() {
var title;
$.ajax( {
type :"POST",
url :"REQ_title.php",
success : function(obj) {
title=obj;
//alert(title);
}
})
alert(title);
}
这段代码无法获取obj的值,请教各位高人我如何能在success : function(obj)的外部获取obj的值,先谢谢各位了
只能在回调函数里面对返回值进行处理。
[code="java"]
var title;
function ess() {
$.ajax( {
type :"POST",
url :"REQ_title.php",
success : function (obj){reslut(obj)}
})
}
function reslut(obj){
title=obj;
//下面你要执行的处理,如alert(title);
}
[/code]
放弃你的想法吧.
ajax是一个异步的操作, 你是不可能在一个函数里面返回一个异步ajax的返回值的
把你要处理的操作放在
[code="java"]
function(obj) {
title=obj;
//alert(title);
}
[/code]
里面