How to use dataType: 'jsonp' but still have application/json in Accept header?

后端 未结 3 481
孤街浪徒
孤街浪徒 2021-01-19 18:20

I want to access a REST service on another domain. If, in JQuery, I specify:

dataType: \'json\'

it fails, as expected, since for cross-doma

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 19:03

    I think you will want to try something along these lines:

    $.ajax({
        headers: { 
            Accept : "application/json; charset=utf-8",
            "Content-Type": "text/plain; charset=utf-8"
        }
        dataType: 'jsonp',
        success : function(response) {
            ...
        }
    })
    

提交回复
热议问题