我这种形式:形式通过Ajax提交不工作
<form method="post" id="userForm" name="userForm" class="form-validate" action="/istuff/index.php/user" >
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="view" value="user"/>
<input type="hidden" name="controller" value="user"/>
<input type="hidden" name="task" value="saveUser"/>
<input type="hidden" name="layout" value="edit_address"/>
<input type="hidden" name="address_type" value="ST"/>
<button class="button" type="submit"
</form>
而且我对这种形式的AJAX脚本:
jQuery(document).ready(function($) {
$("#userForm").live("submit", function (event) {
event.preventDefault();
var form = $(this);
$.ajax({
url: form.attr("action"), // Get the action URL to send AJAX to
type: "POST",
data: form.serialize(), // get all form variables
success: function(result){
// ... do your AJAX post result
}
});
});
});
形式运作良好没有AJAX,但后来我加入这个脚本它不起作用。此外,我试图去到AJAX调用中使用的链接(带有参数的复制位置(带有提交的参数的完整链接) - 它将我重定向到完全不同的页面,然后我提交没有AJAX的表单。
你缺少的数据类型:“???”和contentType:“application/???”在你的ajax调用中 – agentpx 2014-12-27 14:21:08