2011-04-29 28 views
0

我得到了IE瀏覽器奇怪的錯誤..但在這兩個FF和鉻ID,字符串或整數預計用的eval()

沒有問題,當我提醒可變我得到這個:

json_post('delete_accounting', 'json.action.php?action=delete_accounting', 'id=682', 'rtn_accounting', {tr_id:'tr_acc682', enc_id:374, delete:1}); 

但是當我想eval()的刺痛我得到這個錯誤(錯誤是來自丹麥的翻譯,所以我不知道它是怎麼把英語?)

id, string or integer was expected 

編輯:

var xmlhttp = {}; 
function json_post(request_var, response, get_str, callback_function, callback_var) 
{ 
    request_var += Math.floor(Math.random()*999).toString(); 

    CNSTR.mouseLoader.cnstr(); 

    if(window.XMLHttpRequest) xmlhttp[request_var] = new XMLHttpRequest(); 
    else if(window.ActiveXObject) xmlhttp[request_var] = new ActiveXObject('Microsoft.XMLHTTP'); 

    xmlhttp[request_var].open('POST', response, true); 
    xmlhttp[request_var].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 
    xmlhttp[request_var].onreadystatechange = function() 
    { 
     if(xmlhttp[request_var].readyState == 4) 
     { 
      CNSTR.mouseLoader.dstr(); 

      if(callback_function) eval(callback_function+'('+xmlhttp[request_var].responseText+(callback_var ? ', callback_var':'')+')'); 
     } 
    } 
    xmlhttp[request_var].send(get_str); 
} 

我敢肯定的是,在EVAL發生錯誤(),因爲當我運行刺痛作爲真正的代碼沒有問題..

這樣的:

json_post('delete_accounting', 'json.action.php?action=delete_accounting', 'id=682', 'rtn_accounting', {tr_id:'tr_acc682', enc_id:374, delete:1}); 

我有也試圖在最後一個參數中的對象加上引號逃脫回調函數rtn_accounting)一切(了,還是同樣的錯誤在同一個符合的eval()

+0

你能顯示你正在使用的確切代碼嗎? 'json_post'是做什麼的? – 2011-04-29 10:35:11

+0

或者,使用警報(或調試工具...)檢查json_post是否正在運行。 – boisvert 2011-04-29 10:37:36

+0

這個問題是編輯..我不知道如何檢查如果json_post是在IE中運行...我知道的唯一工具是FF中的螢火蟲,但那不是我的問題在哪裏 – clarkk 2011-04-29 10:47:39

回答

0

是工作

json_post('delete_accounting', 'json.action.php?action=delete_accounting', 'id=682', 'rtn_accounting', {'tr_id':'tr_acc682', 'enc_id':374, 'delete':1}); 
+0

'刪除'是一個關鍵詞。行爲符合ECMA3。在ECMA5中這是固定的。 – scheffield 2011-04-29 11:06:33

+0

啊..好吧..那就更有意義了 – clarkk 2011-04-29 11:54:27