编辑: 这就是我需要的:
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
如何仅将响应存储在变量中?
$
里面? - SLaksfunction bar () { alert('Foo'); }
),则不使用$.bar()
调用该函数,而是直接使用bar()
; - Matt