ajax調用成功,後臺方法成功執行 前臺卻報404

3.1ajax調用成功,後臺方法成功執行 前臺卻報404
第一種解決辦法:
這才發現我的ajax要求方法調用成功以後所返回的數據類型應該是json格式,但是我的後臺的方法卻沒有加mvc的註解@ResponseBody。

正確後端代碼



@RequestMapping("/selectEnterprise")
    @ResponseBody
    public JSONArray selectEnterprise(HttpServletRequest request, HttpServletResponse response) 

前端代碼


  $.ajax({
                    type: "post",
                    url: "${cxt}/interview/enterprise/addEnterprise",
                    async: false,
                    dataType: "json",
                    data: {
                        enterpriseName: enterpriseName,
                        enterpriseCode: enterpriseCode,
                        fullName: fullName,
                        mobilePhone: mobilePhone,
                        testNature: testNature,
                        email: email,
                        updateFlag:updateFlag
                    },
                    success: function (backData) {
                        alert("1213");
                        if (backData.status == "0") {
                            layerNotice(backData.message, false);
                        } else {
                            layerNotice(backData.message);
                        }

                    }
                })

第二種解決辦法
這個是在您的ajax的url請求的路徑錯誤的情況下,一般會出現前臺報錯404,那麼只能好好仔細檢查你的url路徑地址。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章