Some problems with ajax form submission

Some problems with ajax form submission

1, the dataType type is wrong

2. The request cannot be sent

 3. The execution of static scripts can be done when the server is disconnected, but this part is not allowed once it involves network requests (ajax). As in the above part of ajax

4. It is not recommended to use .formSerialize() directly to use .serialize(), otherwise some complex controls such as select cannot be serialized

For ajax, the type of dataType is wrong. If the background is successfully executed, it will also return a failure. When submitting a form with ajax, if the control name in jsp is not available in the background receiving object,

Then the request will not be sent, and the $.broser.mins of jquery cannot find the Cannot read property 'msie' of undefined

For example, <select name="pzm" id="zdyMap_P201"></select> is model-driven, but there is no pzm in attribute-driven, $("#submitForm").formSerialize() will cause an error.

Jsp looks wrong: just open the prompt triangle in the console

$.ajax({

url : webUrl + "/chat/offer/submit",

type : "post",

cache : false,

async : true,

//dataType : "json",

data : $("#submitForm").formSerialize(),//$("#submitForm").serialize()

success: function (ret) {

addToChatRecord();

checkChatRecord(0);

$("#pzsp").attr("style","display:none;");

$("#pzsp1").attr("style","display:block;");

var a= $("#zdyMap_P201").val();

$("#pzsp1").innerText=a;

alert($("#pzsp1").innerText);

},

error : function(retMsg) {

addToChatRecord();

checkChatRecord(0);

}

});

 

 

@RequestMapping(value = "/chat/offer/submit", method = RequestMethod.POST)

public void TbConOrdPriceSubmit(HttpSession session, HttpServletRequest request, HttpServletResponse response, Model model, TbConOrdVo tbConOrdVo)

throws EsteelException, IOException {

String currentUserKey = getCurrentUserKey(request, session);

if (!currentUserKey.equals(tbConOrdVo.getCustomerKey())) {

currentUserKey = tbConOrdVo.getCustomerKey();

}

if (!currentUserKey.equals(tbConOrdVo.getTradeCustomerKey()) && !currentUserKey.equals(tbConOrdVo.getTbConobjCustomerKey())) {

response.getWriter().write("Access denied!");

} else {

if (currentUserKey.equals(tbConOrdVo.getTbConobjCustomerKey())) {

tbConOrdVo.setOrdpriceMan("B");

} else {

tbConOrdVo.setOrdpriceMan("A");

}

/* Convert to json first, */

JSONObject object = JSONObject.fromObject(tbConOrdVo);

String tempstr = object.toString();

/* Add name information, and ipAddress information */

tempstr = "{\"objectName\":\"TbConOrdVo\",\"ipAddress\":" + EsteelNetworkUtil.getIpAddress(request) + ",\"object\":" + tempstr + "}";

/* Then write to activemq */

topicSender.sendMessage(tempstr);

System.out.println("====Write to MQ success====");

response.getWriter().write("Success submit!");

}

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326445786&siteId=291194637