Ajax request returns 200 OK, but an error event is fired instead of success

后端 未结 16 2109
难免孤独
难免孤独 2020-11-22 04:12

I have implemented an Ajax request on my website, and I am calling the endpoint from a webpage. It always returns 200 OK, but jQuery execut

16条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-22 04:15

    I have the similar problem but when I tried to remove the datatype:'json' I still have the problem. My error is executing instead of the Success

    function cmd(){
        var data = JSON.stringify(display1());
        $.ajax({
            type: 'POST',
            url: '/cmd',
            contentType:'application/json; charset=utf-8',
            //dataType:"json",
            data: data,
            success: function(res){
                      console.log('Success in running run_id ajax')
                      //$.ajax({
                       //   type: "GET",
                       //   url: "/runid",
                       //   contentType:"application/json; charset=utf-8",
                       //   dataType:"json",
                       //   data: data,
                       //  success:function display_runid(){}
                      // });
            },
            error: function(req, err){ console.log('my message: ' + err); }
        });
    }
    

提交回复
热议问题