2011-09-22 26 views
0

我希望能夠顯示一個加載div在發出ajax請求時,所以我試圖將我的請求從$ .get更改爲$ .ajax,以便我可以使用beforeSubmit並完成操作。製作jquery.get一個jquery.ajax - 不工作?

出於某種原因,得到下面的作品,但阿賈克斯沒有。任何想法爲什麼?該方法被觸發,但在小提琴手,我可以看到沒有請求返回到服務器。

WORKS:

$("#testBoundChart").click(function (e) { 
         $.get('/charter/bound', callbackFn); 
         function callbackFn(data) { 
          //Append markup to dom 
          $('body').append(data); 
          // call the js function from the partialview here 
          generateChart(); 
         } 
        }); 

NO請求而發送的:

  $("#testBoundChart").click(function (e) { 
      alert("triggered"); 
      $.ajax({ 
        url: '/charter/bound', 
        data: data, 
        success: (function(data) { 
         //Append markup to dom 
         alert("success"); 
         $('body').append(data); 
         // call the js function from the partialview here 
         generateChart(); 
        }), 
        error: (function() { 
        alert("error"); 
       }) 
      }); 
     }); 

非常感謝

回答

0

它看起來像你缺少的誤差函數的分號。雖然我不確定它爲什麼不提供Javascript錯誤。

+0

這確實是一個問題。謝謝 – Glinkot

相關問題