I am trying to get some data via ajax but for some reason it gives errors in the console in Chrome and IE only. It works fine in Firefox.
Here is my code:
PHP
function get_data() {
$data = array( 'value' => '50', 'type' => 'box' );
echo json_encode($data);
exit;
}
JS
$(".click").click(function() {
var data = {
action: "get_data"
};
$.post( "http://domain.com/", data, function(response) {
var newResponse = $.parseJSON(response);
console.log(newResponse);
});
});
So this code works fine in Firefox but for some reason it doesn't work in Chrome and IE...In Chrome, it doesn't even get to the console.log function before it errors out.
Thanks for looking.
$.postcallback, does the error go away? I'm wondering if it's coming from the$.parseJSON.