Delegation with forms in jQuery
I have a system, where I am loading forms via Ajax into a predefine开发者_JAVA百科d container. After the form has been loaded, delegate is attached to input boxes and submit event, so that a validate function is launched. Within this validate function a $.post()
method is used to check if the values input in the form are correct.
I want to check if the $.post()
returned an empty json string, so that I could return true
to the function that delegated the event, so that I could submit the form to the server, and reload the content for that container. I am using the function in in this question to get the validation data back, but I can't seem to figure out a way, to return false
or true
to the delegating function. Any way to do this? Thanks!
This is what I ended up doing:
$.ajaxSetup({
async:false
});
This makes the ajax
request into sjax
, if I may say so, and therefore the code i wanted to use, works.
精彩评论