Jquery - jQuery Form Plugin and page reload
i try to build an autosubmit with the Jquery Form Plugin.
for example
$("#my_form").change(function(){
document.my_up_form.submit();
});
The file upload and everything works but i get a page reload. I dont understand that. When use the normal submit button it works (no page reload).
Can somebody tell me what the different between a normal <input type="submit" value="go" />
and the document.myform.submit();
is?
Thanks in advance! Peter
UPDATE Hi Lee, thank you very much for the fast answer.This document.my_up_form.ajaxSubmit();
will n开发者_高级运维ot work but this $('#my_up_form').ajaxSubmit();
do the job.
But know i have a new the problem .. i dont get a answer.
Whats wrong know?
$('#my_up_form').ajaxForm({dataType: 'json', success: processJson});
function processJson(data)
{
if(data['success'] == true)
{
alert('true');
}
else
{
alert('false');
}
}
The jquery ajaxForm
modifies the submit button so that it calls ajaxSubmit()
instead of the browser's normal action. When you call submit()
you're invoking the browser's normal action. you should call ajaxSubmit()
instead.
$("#my_form").change(function(){
document.my_up_form.ajaxSubmit();
});
Check the "API" tab on the same documentation page you linked.
精彩评论