jquery ajax post says xxx not allowed by Access-Control-Allow-Origin

后端 未结 3 1704
难免孤独
难免孤独 2021-01-14 16:43

I was trying to call eBay FindProducts API using AJAX (post request) but was stuck at the following error:

XMLHttpRequest cannot load htt

3条回答
  •  难免孤独
    2021-01-14 17:02

    If you add &responseencoding=JSON to your URL you will get the response as JSON according to docs

    UPDATE Working example. What I've done is that I changed to dataType:'jsonp' added jsonp:'callbackname'. Because jQuery by default calls the callback parameter callback, but eBay expect it to be called callbackname. What you have to do is add your parameters to the data map. Make sure you use the correct parameter names, check the docs and use the URL method not the header method. Hope this helps.

提交回复
热议问题