I am having an ajax problem. I am doing cross domain, i.e I am submitting a form on another domain.
Here is my js code:
$.ajax({
url: $(this).attr('action'),
type: $(this).attr('method'),
data: $(this).serialize(),
dataType: 'json'
})
.done(function(data) {
console.log('what');
})
;
and in php I am returning this string:
$response = "Hmmm... Please contact the webmaster at contact@vahana.io as it seems that there is a problem with submitting this form. Error x02";
echo json_encode(['response' => $response]);
I did understood from my searches that I should in my dataType use jsonp instead of json, but with jsonp I cant even submit my form.
When I submit my form with json, the data is properly inserted in my DB but I cant get any response. I tried the .success instead of .done but does not work either.
My first question, can I do cross domain with json or not.
If I need to use jsonp, how do I check in my browser that everything is going right, and how should I modify my response because right now if I use jsonp I am having an error in the console because of the ':' which seperate the key from the value.
Thanks for your help