How to implement a PUT call with JSON data using AJAX and JQuery?

后端 未结 3 1793
情书的邮戳
情书的邮戳 2021-02-07 08:31

I\'ve looked around and tried many different methods, but can\'t seem to pass actual data to my controller\'s function.

Here is some code:

        var UR         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 09:14

    $.ajax({
            url: window.serverUrl + 'student/event/' + eventId,
            type: 'put',
            data: JSON.stringify(data),
            headers: {
                'x-auth-token': localStorage.accessToken,
                "Content-Type": "application/json"
            },
            dataType: 'json'
    })
    

    This worked for me

提交回复
热议问题