I'm trying to complete an AJAX get request, using JSONP as my datatype to get around a CORS error that I was getting earlier. My javascript is as follows:
var search = document.getElementById("search_term").value;
$(document).ready(function () {
const url = "http://myurl/" + search;
$('.btn').click(function () {
$.ajax({
type: "GET",
url: url,
dataType: "jsonp",
success: function (response) {
console.log(response)
},
error: function (a, b, c) {
console.log('Error ' + a)
console.log(b)
console.log(c)
}
})
})
})
I have also tried including jsonp: false in the AJAX parameters as well as declaring a callback function, but haven't been able to have the request successfully complete, instead always entering the "error" portion of my ajax call.
The errors I receive (for the code as seen above) is as follows:
a = Error [object Object]
b = parseerror
c=
Error: "jQuery3410699381665356_1582645983199 was not called"
jQuery 7
error
e.converters["script json"]
s
l
i
dispatch
handle
As the title of this question says, the request shows as status 200 and the response payload is accurate to what I'm trying to receive.