JSON Post with Customized HTTPHeader Field

后端 未结 4 1534
后悔当初
后悔当初 2020-12-04 19:24

I have inherited some code that will eventually be part of an API call. Based on the existing code, the call is a post to retrieve JSON code with an access_token. While this

4条回答
  •  悲哀的现实
    2020-12-04 19:34

    I tried as you mentioned, but only first parameter is going through and rest all are appearing in the server as undefined. I am passing JSONWebToken as part of header.

    .ajax({
        url: 'api/outletadd',
        type: 'post',
        data: { outletname:outletname , addressA:addressA , addressB:addressB, city:city , postcode:postcode , state:state , country:country , menuid:menuid },
        headers: {
            authorization: storedJWT
        },
        dataType: 'json',
        success: function (data){
            alert("Outlet Created");
        },
        error: function (data){
            alert("Outlet Creation Failed, please try again.");        
        }
    
        });
    

提交回复
热议问题