I have a bug where my code won't exit my routine. I'm using a return statement... but it doesn't seem to be working.
I have the following code inside a click event:
$.getJSON(
url = 'myserver/controller/checkforduplicate',
parameters,
function(data) {
if (data=='true') {
alert(data);
$('#verror').html("A duplicate entry exists");
return false;
}
}
);
console.log($('#myform').serialize() );
When I input data the should be considered a duplicate and trigger this click event, the system doesn't exit but still gets to the console.log statement.
EDIT 1
I've reviewed the answers found at: How do I return the response from an asynchronous call? But from what I'm reading, haven't I already defined a callback function? I thought that's what I was doing with the "function(data) {}" code... In addition to stackoverflow, I've been using:
http://www.tutorialspoint.com/jquery/ajax-jquery-getjson.htm
It seems that in the above example, they are referring to their function(jd) as the callback. According to the above article, the syntax is:
$.getJSON( url, [data], [callback] )
Perhaps I'm still missing something... Thanks for your patience.