This is my code example
var formValidate = function() {
var url = 'someurl';
var checkC = function (url, callback) {
$.get(url, function( data ) {
if(data.indexOf('OK') == 0) return callback('OK');
})
};
checkC(url, function(data) {
if(data == 'OK') return false;
});
return true;
}
My code is pretty similar to Adam Rackis's in this question Wait for jQuery $.get function to finish before running code. But unfortunately function dont wait for the data return. formValidate() just return true. I want use this function to check some conditions before sending data to server from form
form.on('submit', function(){
if(formValidate()) form_send();
})
Can someone tell me where was I wrong in code above?