用一个ajax查多个查询,防止多个Ajax查询

我有一个灯箱形式在框中工作的新条目添加到我datatable形式与此代码:防止多个Ajax查询

$("#add-quotation").click(function(event) {

event.preventDefault();

var customer_id = $(this).attr('data-customer');

$.nmManual(

'#quotation_manage',{

sizes: { // Size information

w: 500, // Initial width

h: 500 // Initial height

}

});

$('#quotation_submit').live('click', function(event){

event.preventDefault();

if(typeof($.nmTop()) != "undefined"){

$.nmTop().close();

}

var loading = $('.loading-notification');

loading.removeClass('hidden');

var date = $('#date_activate').val();

var budget = $('#budget').val();

var hospital = [$('#hospital').val(), $('#hospital option:selected').text()];

var dental = [$('#hospital').val(), $('#hospital option:selected').text()];

var optical = [$('#optical').val(), $('#optical option:selected').text()];

var doctor = [$('#doctor').val(), $('#doctor option:selected').text()];

$.ajax({

type: 'POST',

data: 'create=true&customer_id=' + customer_id + '&date=' + date + '&budget=' + budget + '&hospital=' + hospital[0] + '&dental=' + dental[0] + '&optical=' + optical[0] + '&doctor=' + doctor[0],

url: 'quotation.php',

dataType: 'json',

async: false,

success: function(result){

if (result){

oTable.fnAddData([

result.id,

result.date,

budget,

hospital[1],

dental[1],

optical[1],

doctor[1],

'',

'',

'',

'test'

]);

}

loading.addClass('hidden');

}

});

});

});

它工作得很好,但有时它发送3个或更多的查询,我怎样才能防止这个?通常它应该只发送一个查询。

2011-12-12

Awea

+0

是该事件'$( “#附加报​​价”)。单击(''中创建的document.ready()'?有的时候'click'事件创建的多个时间代码和你确实有这种行为 –

+0

它创建在页面末尾 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值