ajax数据提交失败!!!

-江流儿- 2017-06-15 03:16:00
<form action="/order/create" id="order-form" method="post" name="Form2">
<div class="clearfix">
[#list specifications as ss]
<label class="field-label">${ss.specification.name}</label>
<div class="form-item shop">
<input type="hidden" name="product_id" value="${product.id}">
<input type="hidden" name="product_name" value="${product.name}">
<input type="hidden" name="project" value="${project}"/>
<input type="hidden" id="uid" name="uid" value="${uid}"/>
<input type="hidden" id="items" name="items" />
<!--<input type="hidden" name="actionurl" id="actionurl" value="http://shop.chaodaohaigou.com/success/index.html">-->
<!--<input type="hidden" name="sGoodsColor" id="sGoodsColor" value="">-->
<!--<input type="hidden" name="nGoodsId" id="nGoodsId" value="3">-->
<!--<input type="hidden" name="nGoodsNumber" id="nGoodsNumber" value="1">-->
<!--<input type="hidden" name="nPayState" id="nPayState" value="1">-->
<!--<input type="hidden" name="pmoney" id="pmoney" value="498">-->
<!--<input type="hidden" name="nTotalMoney" id="nTotalMoney" value="298">-->
<!--<input type="hidden" name="sClientId" id="sClientId" value="11002">-->
<!--<input type="radio" name="sGoodsName" id="sGoodsName" checked="" value="${product.name}${product.name}-->
[#list ss.specificationValues as v]
<p>
<input type="radio" name="items" checked="checked">
<label>${v.name}</label>
</p>
[/#list]
</div>
[/#list]
</div>
<div class="clearfix">
<label></label>
<div class="form-item color">
<p><input type="radio" name="sOtherClass" id="hei" checked="" value="${product.name}"><label for="hei">${product.name}<img src="${webctx}/resources/model9/hot.gif" alt=""></label></p>
</div>
</div>
<div class="clearfix">
<label for="price">金额</label>
<div class="form-item">
<input type="text" id="price" name="price" value="${product.price}元" disabled="">
</div>
</div>
<div class="clearfix">
<label for="name"></label>
<div class="form-item">
<input type="text" id="name" name="name" placeholder="姓名">
</div>
</div>
<div class="clearfix">
<label for="mobile">手机</label>
<div class="form-item">
<input type="text" id="mobile" name="mob" placeholder="填写正确的手机号码">
</div>
</div>
</div>
</div>
<div class="clearfix submit">
<a id="submit-btn" class="btn-submit">提交</a>
<!--<button type="button" class="submit-btn" id="submit-btn">提交</button>-->
</div>
</form>

------------------------------------------------------------------------------------------------------------------------------------------------------------------

btn.on('click',function(){
if(verify()){
var url = "/order/create";
$.ajax({
type: "POST",
dataType: "json",
url:url,
data: $('#order-form').serialize(),
success: function (result) {
var myDate = new Date();
window.location.href = "/resources/common/success.htm?name=" + "product_name"+product.name + "&price=" + product.price;
},
error: function(data) {
alert("服务器繁忙,请重新提交!");
}
});
$("#mobile").val('');
$("#name").val('');
$("#address").val('');
$("#remark").val('');


为什么在页面提交数据总是走到失败error方法里面???
是url错误了吗(url的路径要写哪个路径啊)
还是不可以用ajax提交只能用表单提交


...全文
308 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
-江流儿- 2017-06-17
  • 打赏
  • 举报
回复
引用 1 楼 a411878915 的回复:
你这个url 看起来很不对劲啊, url: "${pageContext.request.contextPath}/publicManageAction.do?method=dosometh ${pageContext.request.contextPath} 表示你的项目名 url:项目名/action?method (struts1) url:项目名/action (strtus2)
获取页面数据通过ajax转换成json字符串传到服务器 就是把信息填写完了点击添加按钮走到error方法里面去了 感觉url没有错误啊
a411878915 2017-06-16
  • 打赏
  • 举报
回复
你这个url 看起来很不对劲啊, url: "${pageContext.request.contextPath}/publicManageAction.do?method=dosometh ${pageContext.request.contextPath} 表示你的项目名 url:项目名/action?method (struts1) url:项目名/action (strtus2)

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧