I've got an ajax call to the following php method:
public function test(){
die(json_encode(['test' => 'test1']));
}
My ajax call works when set as GET but not as POST. The GET call is:
$.ajax({
type: 'get',
url: url,
success: function(msg) {
log(msg);
},
dataType: 'json'
});
Which successfully returns the JSON element. But when I set it as POST:
$.ajax({
type: 'post',
url: url,
success: function(msg) {
log(msg);
},
dataType: 'json'
});
Returns nothing. If I removed the dataType it will return the whole webpage where it's being triggered from.
I do need to make the request as POST since I'll be sending a large amount of data.
Thanks.