2013-07-31 65 views
0

我試圖在用戶單擊按鈕(onclick="Website.submit()")時調用JavaScript中的函數,但我的代碼不起作用。未捕獲的類型錯誤:非法調用(chrome)

我在Chrome收到此錯誤:

Uncaught TypeError: Illegal invocation

在Chrome中,這條線在jquery.js highligted作爲錯誤的來源:

// If value is a function, invoke it and return its value 

value = jQuery.isFunction(value) ? value() : (value == null ? "" : value); 

對開發商面板的控制檯更詳細的錯誤標籤(F12):

Uncaught TypeError: Illegal invocation in Chrome

下面是代碼:

var Website = { 

    submit: function() { 

    var stap1 = $('#stap1').val(); 
    var stap2 = $('#stap2').val(); 
    var stap3 = $('#stap3').val(); 
    var letop = $('#letop').val(); 

    if (stap1.length == 0) { 
     $('#error2').show(); 
     $('#the_error2').html('Je moet alle velden invullen om door te gaan.'); 

     $('#stap1').css({ 
     'border-width': '1px', 
     'border-color': 'red' 
     }); 
    } 

    if (stap2.length == 0) { 
     $('#error2').show(); 
     $('#the_error2').html('Je moet alle velden invullen om door te gaan.'); 

     $('#stap2').css({ 
     'border-width': '1px', 
     'border-color': 'red' 
     }); 
    } 

    if (stap3.length == 0) { 
     $('#error2').show(); 
     $('#the_error2').html('Je moet alle velden invullen om door te gaan.'); 

     $('#stap3').css({ 
     'border-width': '1px', 
     'border-color': 'red' 
     }); 
    } 

    if (letop.length == 0) { 
     $('#error2').show(); 
     $('#the_error2').html('Je moet alle velden invullen om door te gaan.'); 

     $('#letop').css({ 
     'border-width': '1px', 
     'border-color': 'red' 
     }); 
    } 

    if (stap1.length !== 0 && stap2.length !== 0 && stap3.length !== 0 && letop.length !== 0) { 

     $.post(General.url + "/pages/website_check.php", { 
     naam: naam, 
     subdomein: subdomein, 
     stap1: stap1, 
     stap2: stap2, 
     stap3: stap3, 
     letop: letop 
     }, function (result) { 

     if (result == 1) { 
      $('#error2').show(); 
      $('#the_error2').html('Deze naam is al in gebruik. Ga snel terug en kies een andere.'); 

      $('#error').show(); 
      $('#the_error').html('Deze naam is al in gebruik. Kies een andere.'); 

      $('#naam').css({ 
      'border-width': '1px', 
      'border-color': 'red' 
      }); 

     } else { 
      if (result == 2) { 
      $('#error2').show(); 
      $('#the_error2').html('Dit subdomein is al in gebruik. Ga snel terug en kies een andere.'); 

      $('#error').show(); 
      $('#the_error').html('Dit subdomein is al in gebruik. Kies een andere.'); 

      $('#subdomein').css({ 
       'border-width': '1px', 
       'border-color': 'red' 
      }); 
      } 
     } 
     }); 
    } 
    } 

}; 
+0

你發帖不是腳本不同的域是從裝? – obecker

+0

不,它是一樣的General.url給我我自己的本地主機。 – user2629980

+1

general.js的第128行和第128行的內容是什麼? –

回答

0

只是註釋行 值= jQuery.isFunction(值)? value():(value == null?「」:value); jQuery.js中的 。

add = function(key, value) { 
     // If value is a function, invoke it and return its value 
     //value = jQuery.isFunction(value) ? value() : (value == null ? "" : value); 
     s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); 
    };