【发布时间】:2014-12-05 10:54:06
【问题描述】:
我正在使用以下表单进行序列化和提交,但它没有提交给定的表单
HTML
<form action="" id="post_message_form">
<textarea name="message" style="width:100%;height:80px" id="text_message" cssClass="form-control"></textarea>
<input type="hidden" name="postImageseList[0].largePicPath" class="img-dtl" value="/img/post/large/0020603xpd4ps7ew_1_7gwy2kc44f141777.jpg" />
<input type="hidden" name="postImageseList[1].largePicPath" class="img-dtl" value="/img/post/large/0020603xpd4ps7ew_1_7gwy2kc44f141666.jpg" />
<button type="submit" id="submit_status_button">Submit</button>
</form>
jQuery
$("#post_message_form").on("submit", function (f) {
f.preventDefault();
console.log($("#post_message_form").serialize());
alert($("#post_message_form").serialize());
$.ajax({
type: 'POST',
url: 'PostMessage',
data: $("#post_message_form").serialize(),
dataType: "text html",
success: function (data) {
}
}).fail(function (xhr, status, error) {
alert("Error");
alert('error status:' + status);
});
});
字段name="postImageseList[0].largePicPath" 是动态生成的字段,它可能是0 或更多。
如何序列化上面的表格。
我试过了here
【问题讨论】:
-
似乎没问题。 “url:'PostMessage'”看起来很奇怪
-
您需要在 ajax 调用中提供正确的 url。那么它应该可以正常工作。
-
PostMessage 有什么问题
-
@user3263194 以上代码是否正确
-
你能解释一下什么是'PostMessage'吗?你是指这里的一些jsp页面吗?那么你需要添加 .jsp
标签: jquery forms jsp serialization