編輯: 這就是我需要:如何在變量中返回帖子的回覆? jQuery的
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");
},
我想做出點像這樣:
in:
$.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
如何只返回變量中的反應呢?
爲什麼地球上,你把所有的功能'$'裏面? – SLaks 2010-04-25 15:50:43
如果沒有我得到:$。functionname不是函數 – robertdd 2010-04-25 15:55:39
*哭*。 $是jQuery對象。如果你通常定義函數('function bar(){alert('Foo');}'),你不用'$ .bar()'調用函數,它只是'bar()'; – Matt 2010-04-25 16:01:23