Setting processData to false in jQuery breaks my AJAX request

后端 未结 3 483
名媛妹妹
名媛妹妹 2020-11-28 12:15

I\'ve googled for a while now and can only find what processData: false does. I can\'t find anyone who has experienced this same issue.

I\'m passing JSO

3条回答
  •  无人及你
    2020-11-28 12:46

    You want to pass the data as JSON. You are passing a Javascript object. JSON is a way of serializing Javascript objects to strings so that they can be passed around without compatibility issues.

    You actually want to pass the JSON in a string:

    $.ajax({
        url: myUrl,
        type: "POST",
        data: '{"foo": "bar"}',
        processData: false,
        contentType: 'application/json'
    });
    

提交回复
热议问题