(Function) error - A function to be called if the request fails. The function gets passed two arguments: The XMLHttpRequest object and a string describing the type of error that occurred.而我的程式在 success 時的 callback function 卻也是以回傳一個 XMLHttpRequest 物件的方式來寫的,因此當事實上回傳的已經是一個字串時,也就不會有 responseText 囉(因為回傳值本身就是responseText),然後 callback function 就理所當然的死掉了。
(Function) success - A function to be called if the request succeeds. The function gets passed one argument: The data returned from the server, formatted according to the ‘dataType’ parameter.
(Function) complete - A function to be called when the request finishes. The function gets passed two arguments: The XMLHttpRequest object and a string describing the type the success of the request.
function successCallBack(XMLHttpRequestObject){改成
eval(”var jsonVars = ” + XMLHttpRequestObject.responseText);
………
}
function successCallBack(responseText){而我選的是後者。
eval(”var jsonVars = ” + responseText);
………
}
| 歡迎光臨 中央論壇 - CENTER BBS (https://centerbbs.com/) | Powered by Discuz! X3 |