【发布时间】:2011-02-12 02:36:52
【问题描述】:
已编辑: 这就是我需要的:
sendpost = function(a,b,c){
return jQuery.post('inc/operations.php', {a:b}, c, "json");
},
rotate = function(callback){
//....
alert(callback);
}
sendpost('operation', 'test', rotate)
旧帖: 我使用这个函数来返回帖子的响应:
$.sendpost = function(){
return jQuery.post('inc/operations.php', {'operation':'test'}, "json");
},
我想做这样的事情:
在:
$.another = function(){
var sendpost = $.sendpost();
alert(sendpost);
}
但我得到:[object XMLHttpRequest]
如果我打印对象:
jQuery.each(sendpost, function(i, val) {
$(".displaydetails").append(i + " => " + val + "<br/>");
});
我明白了:
details abort => function () { x && h.call(x); g("abort"); }
dispatchEvent => function dispatchEvent() { [native code] }
removeEventListener => function removeEventListener() { [native code] }
open => function open() { [native code] }
setRequestHeader => function setRequestHeader() { [native code] }
onreadystatechange => [xpconnect wrapped nsIDOMEventListener]
send => function send() { [native code] }
readyState => 4
status => 200
getResponseHeader => function getResponseHeader() { [native code] }
responseText => mdaaa from php
如何只返回变量中的响应?
【问题讨论】:
-
你到底为什么要把你所有的函数都放在
$里面? -
如果我没有得到:$.functionname 不是函数
-
哭泣。 $ 是 jQuery 对象。如果你正常定义函数(
function bar () { alert('Foo'); }),你不要使用$.bar()调用函数,它只是bar();
标签: php jquery return-value