Reputation: 1579
Okay so when I usually work with JSON I collect data like this:
<?php
$some_array = array("success" => "The upload is successful", "failed" => "The upload has failed");
echo json_encode($some_array);
?>
<script type="text/javascript">
success: function(data){
var imported = $.parseJSON(data);
...
}
</script>
but I I'm currently trying to figure a jquery plugin that uses responseJSON and I'm not sure how to use it:
onComplete: function(id, fileName, responseJSON) {
if (responseJSON.success) {
How does this work?
Upvotes: 1
Views: 158
Reputation: 22329
You can console.log(responseJSON)
to get a look at the complete object.
Edit
The main difference here I would say is that data
is a JSON string and accessing it as an object requires one to use parseJSON
on it.
It seems responseJSON
is already a JSON serialized object and as such you are able to immediately access it's properties without the need to use parseJSON
.
Upvotes: 1