我想在我的函数中使$.get()方法同步.在ajax aysnc:false帮助我,现在我如何对$.get()做同样的事情
var ifsc_code = $('#ifsc-code').val();
var api_url = 'http://api.techm.co.in/api/v1/ifsc/'+ifsc_code;
$.get(api_url,function(data,status){
//console.log(data.status);
var status = data.status;
if (data.status == "success") {
$.each(data,function(key,value){
var address = value.BANK+"," + value.BRANCH+"," + value.ADDRESS ;
$('.bank-details').removeClass('no-ifsc').text(address);
});
var res = "true";
alert('inside checkIfsc true');
return res;
}
else if (data.status == "failure") {
$('.bank-details').addClass('no-ifsc').text(data.message);
var res = "false";
alert('inside checkIfsc false');
return res;
}
或者还有其他方法可以做同样的事情吗?
最佳答案
$.get也接受这样的参数
$.get({
url: url,// mandatory
data: data,success: success,dataType: dataType,async:false // to make it synchronous
})