我有一個JavaScript的快速問題:
我有以下代碼行顯示了一個例子,它工作正常。你可以訪問passeddata沒有問題。
$.getJSON(jsonUrl,function(passeddata){
alert("it worked ");
});
下一個代碼示例不起作用,失敗,出現以下錯誤:
Uncaught TypeError: Object ReferenceError: passeddata is not defined has no method 'replace' jq.html:177 (anonymous function)
$.getJSON(jsonUrl, something(passeddata));
function something(passeddata)
{
var jasondata = passeddata;
alert("it worked ");
}
有人能解釋這個問題?我知道它可能很明顯,但我無法找到答案。
從'$ .getJSON(jsonUrl,something(passeddata));'中移除'(passeddata)'''。 –