Answer the question
In order to leave comments, you need to log in
Cross domain request from http to https via ajax or fetch?
dataType: jsonp is not supported.
There are two options, both don't work:
1) Ajax.
$.ajax(api, {
crossDomain: true
success: (data)=>{
console.log(data);
},
});
fetch(api, {
mode: "cors",
});
queryPromise.then((response)=>{
console.log(data);
})
Answer the question
In order to leave comments, you need to log in
Firstly, cross-domain requests only work when the server returns Allow-Control-Allow-Origin: *
Secondly, you can try to put processData: false
in the parameters of your ajax request.
$.ajax({
type: "POST",
url: api_url,
contentType: "application/x-www-form-urlencoded; charset=UTF-8",
processData: false,
data: JSON.stringify(pd),
success: function (result) {
// ...
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question