ajax multiple request
i am sending multiple ajax requests at a same time as ajax sends Asynchronous request but i want to execute second request until i get my first response. as first response may dependent on second one and so on .
here is my code
$.ajax({
'url':'<?php echo $html->url(array('controller'=>'users','action'=>'priceofitem'));?>/'+menu_item_id,
'type':'POST',
success:function(result) {
var price= valu*parseFloat(result);
$开发者_运维问答('.total-price').html(price);
}
});
Anybody have any idea??
Use ajaxQueue for this purpose
See the links
http://docs.jquery.com/AjaxQueue
http://code.google.com/p/jquery-ajaxq/
http://www.onemoretake.com/2009/10/11/ajaxqueue-and-jquery-1-3/
You need to send syncronious request, and specify async :false
success:function(result)
{
var price= valu*parseFloat(result);
$('.total-price').html(price);
},
async: false
set async:false
e.g.
$.ajax({
url:'<?php echo $html->url(array('controller'=>'users','action'=>'priceofitem'));?>/'+menu_item_id,
type:'POST',
async:false,
success:function(result) {
var price= valu*parseFloat(result);
$('.total-price').html(price);
}
});
精彩评论