here is the response code
echo json_encode( array('success' => $stat,'msg'=>$file));
return from the server response
Object {success: "success", msg: "2017_nissan_gtr-2560x14409.jpg"}
here is the response code
echo json_encode( array('success' => $stat,'msg'=>$file));
return from the server response
Object {success: "success", msg: "2017_nissan_gtr-2560x14409.jpg"}
var response = {success: "success", msg: "2017_nissan_gtr-2560x14409.jpg"}
var success = response.success;
var msg = response.msg;
You can iterate object by below code.
var obj= {success: "success", msg: "2017_nissan_gtr-2560x14409.jpg"}
for(var i in obj)
{
alert(i+" :: "+ obj[i]);
}
You can use Object.keys()
:
var respObj = {
success: "success",
msg: "2017_nissan_gtr-2560x14409.jpg"
}
Object.keys(respObj).forEach(function(k) {
console.log('key::::>', k,' value::::> ', respObj[k]);
})
U can iterate through the object properties using the following code..
$.each(obj, function (key, value) { });