JQuery的提交没有在Chrome中工作 [英] JQuery submit not working in Chrome

查看:184
本文介绍了JQuery的提交没有在Chrome中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是形式

@using (Html.BeginForm(MVC.CollectionPlanConfirmation.ActionNames.Edit, MVC.CollectionPlanConfirmation.Name, FormMethod.Post, new { @id = "collectionPlanForm" }))
{
.................
}

提交按钮是外在形式。以下是提交我的MVC视图按钮。

Submit button is outside Form. Following is the submit button on my MVC view.

<input type="submit" value="Save" class="aSubmit" onclick="return SubmitForm();" />

以下是应该提交表单jquery的。

Following is the jquery that should submit the form.

<script type="text/javascript">    
function SubmitForm() {
...... validation code........
$('#collectionPlanForm').submit();
}
</script>

我可以看到,IE8和Firefox提交表单,但它不适用于Chrome顺利。它不会在所有做任何事情。

I could see, IE8, and Firefox submitting the form, but it doesn't go well with Chrome. It doesn't do anything at all.

可能是什么原因,以及如何解决它?

What could be the reason, and how to fix it?

任何帮助,多AP preciated。

Any help on this, much appreciated.

感谢

推荐答案

执行jQuery的一个提交最好的办法就是用这种方式。

The best way to perform a submit for jquery is in this way.

$('#submitButton').click( function() {
    $.ajax({
        url: 'some-url',
        type: 'post',
        dataType: 'json',
        data: $('form#myForm').serialize(),
        success: function(data) {
             console.log("success");
        }
    });
});

http://jsfiddle.net/BD3Rt/

总是好的,保持干净的HTML和你分开的jQuery / JavaScript的code。

Always nice to keep html clean and separate your jquery/javascript code.

这篇关于JQuery的提交没有在Chrome中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆