ajax and returned value after onclick button
Hi,
I have a form to validate before submiting the values. I need to make some validation on client side and another control on the server.
My code looks like:
<input type="btnSubmit" value="Submit" onclick="return SubmitData();" />
function SubmitData(){
//do some control on client side
....
//Call server method for getting some info
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
url: currentUrl + "/IsTotalTypeFilesReached",
data: "{param:'some data to control'}",
success: function(result) {
if (result.d == "0")
return false;
else
return true;
}
});
}
My issue is how to return the result of my success function to my SubmitData to say all is ok (true) or not ok (false) ?
In fact the return in the ajax success function doesn't return it to SubmitData. That is my issue how to redirect the value returned by the success function to the onClick event ?
Sam