javascript - Passing json_encoded array to jQuery -


i trying pass array creating in php using json_encode(). running ajax request, see follows:

ajax call:

$.ajax({         type: "post",         url: "../includes/ajax.php?imagemeta=1",         data: {             'id' : $(this).attr('id')         },         datatype:"json",         success: function(data) {             console.log(data);             console.log(data["image_height"]);         },         error: function(data) {             console.log(data);         }     }); 

php json response:

if(isset($_get["imagemeta"])){  $id = intval($_post["id"]); $path = "../uploads/images/" . $fm->selectimagebyid($id); $meta = array();  list($width, $height) = getimagesize($path); $meta["image_height"]   = $height . 'px'; $meta["image_width"]    = $width . 'px';  print json_encode($meta); 

}

although, console.log(data) returns following: {"image_height":"1374px","image_width":"920px"}

the following line console.log(data["image_height"]) returns undefined.

i have tried multiple attempts , have read through majority of top rated questions regarding subject. new json encoding please inform me if have misunderstanding somewhere.

datatype:"json", 

should be:

datatype:"json",     ^ 

javascript case-sensitive.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -