for the purpose of modifying a wordpress plugin to send sms notification i am trying to make an http request using jquery.post() event inside success response of another http request, but 2nd http request not working, it doesn’t return any response, what’s wrong with my code?
//first http request
jQuery.post(redi_restaurant_reservation.ajaxurl, data, function (response) {
jQuery('#redi-restaurant-step3').attr('disabled', false);
jQuery('#step3load').hide();
if (response['Error']) {
jQuery('#step3errors').html(response['Error']).show('slow');
} else {
var smsurl = 'http://sms.mysitename.com/SendSms.aspx?uid=myuserId&pass=123&contact=phone&sms=smstext&rnd=randomnumber';
alert(smsurl);
//
//2nd http request. problem arises from here............
jQuery.post(smsurl, function (a) {
alert('hello'); //not show any alert here
if (a['Error']) {
alert('if');
jQuery('#step3errors').html(a['Error']).show('slow');
} else {
alert('successfully sent');
}
}, 'json');
ga_event('Reservation confirmed', '');
jQuery('#step1').hide('slow');
jQuery('#step2').hide('slow');
jQuery('#step3').hide('slow');
jQuery('#step4').show('slow'); //success message
jQuery('html, body').animate({scrollTop: 0}, 'slow');
}
}, 'json');
in my case all the trouble belong to this line-
jQuery.post() event can’t directly working with this url,
so i modified my code like below and it works like charm!!
and my sendsms.php performs CURL request and return my desired response ..
hope this helps another. 🙂
Nothing wrong with your code, exept POST is working only for same domain