我正在使用帶Prototype庫的Ajax。在原型中的onSuccess函數內部設置訪問值
這是我調用Ajax函數的函數。
function Testfn()
{
var DateExists = '';
new Ajax.Request('testurl',{
method: 'post',
parameters: {param1:"A", param2:"B", param3:"C"},
onSuccess: function(response){
//DateExists = response.responseText;
DateExists = 1;
}
});
// I want to access the value set in the onsuccess function here
alert(DateExists);
}
當我提醒DateExists值我得到的而不是在我的Ajax調用是1的功能的onSuccess設置的值空值這怎麼可能?
感謝您的任何幫助。
誠實的問題:如果我迅速做出反應的一個問題,但留下我的答案不完整,然後再花幾分鐘的時間回去編輯我的答案,它是否顯示爲在原始發佈日期已被回答?因爲在這個問題中,我在上面的兩個答案之前發佈了這個js示例,但現在看起來好像我複製了它們。 – stereoscott 2009-08-07 06:03:18
它顯示您原始回覆的時間。 – hobodave 2009-08-07 06:13:11