Ajax and axios request data are different

question: php API, data can be requested with ajax request, but not with axios request.

< H2 > axios < / H2 >

Code:

    getJson(){
        this.axios({
            method:"post",
            url:"vip/index.php",
            data:{
                "name":"qq.com",
                "videoUrl":"https://v.qq.com/detail/6/639agzdh10yu2q2.html"
            }
        }).then(res=>{
            //console.log(res.data);
            this.msg = res.data;
            console.log(this.msg)
        })
    }

Screenshot

clipboard.png
clipboard.png

ajax

:


:
clipboard.png

clipboard.png

Apr.02,2021

jq ajax if not set,
Content-Type is application/x-www-form-urlencoded
axios , then
if data is the string Content-Type is application/x-www-form-urlencoded
if data is the object Content-Type is application/json .

you should post two request headers instead of response headers
if the request headers are the same, it's a problem with other configurations


your axios request data is incorrect. Take a look at network request payload


axoi setting Content-Type:application/x-www-form-urlencoded give it a try.
refer to axios to send post request. Request.getParamter cannot receive


a 8080, a 8088.

Menu