I have issue with multiple ajax submits. Whenever I click on button submit for every click is one more ajax POST called.
Code bellow
submitHandler: function(form,event) {
//show popup phonenumber check
//check captcha on server side
var fm = $(form);
$(fm).unbind('submit').submit();
$("#registration_phone_check").fadeIn();
var country_number = $("#myDropdown")[0].innerText+fm[0].elements['phone'].value;
country_number = country_number.replace(/(
|
|)/gm,"");//delete all break lines in string
$("#phone_check").val(country_number);
//send code
$("#check_phone_send_code").click(function(e){
e.preventDefault();
var language = "en";
$("#phone_confirmations").fadeIn();
ajax.post('/'+language+'/registration', {
email:fm[0].elements['email'].value,
uname:fm[0].elements['uname'].value,
surname:fm[0].elements['surname'].value,
birthday:fm[0].elements['birthday'].value,
password:fm[0].elements['password'].value,
phone:$("#phone_check").val(),
grecaptcha_response:grecaptcha.getResponse()
}).done(function(resp) {
//code when ajax success or some error is returned
}).fail(function(resp){
grecaptcha.reset();
});
});
},
So the question is, how can I send ajax only once without multiple ajax POST requests.