2013-02-25 41 views
-1

我正在使用jquery构建响应框(ajax)。在框中的Ajax请求

用ajax调用发送请求并等待json响应并使用响应并显示一个信息框。

JSON返回:

$(document).ready(function(){ 
    // disable the form submit 
    e.preventDefault(); 
    //Button click event 
    $("#operation").click(function(e){ 
     //Disabling button 
     $("#operation").attr('disabled', 'disabled'); 
     // get the input data 
     var input = $("#nameImport").val(); 
     //Perform POST for triggering long running operation 
     $.get('update', { 
      name: input 
     }, function(data){ 
      onSuccessImport(data); 
     }, "json"); 
    }); 
}); 

感谢。

+0

那么问题是什么? – 2013-02-25 13:29:29

+0

你想做什么? – coder 2013-02-25 13:30:26

回答

0

我看到的是e.preventDefault()应该去click处理程序中唯一的问题..

//Button click event 
$("#operation").click(function(e){ 
    // disable the form submit 
    e.preventDefault(); 

和一个更通用的评论是,你应该使用.prop与DOM属性拨弄(代替的.attr
所以使用

$("#operation").prop('disabled', true); 
+0

好的,是正确的。 – 2013-02-25 20:55:00