javascript - Determine response from PHP in jQuery -


All, I have a function that is originally triggered when an upload ends. I have the following code in that function:

  onFinish: function (e, data) {console.log (data.result); },   

When I do this, I get the following response in my console:

  [["" ":" 1_3266_671641333369_14800358_42187036_5237378_n.jpg " , "Size": 35535, "Type": "Image \" / jpeg "," url ":" \ / web \ upload upload / \ / 1_3266_671641333369_14800358_42187036_5237378_n.jpg "," delete_url ":" \ / web \ /upload.php? File = 1_3266_671641333369_14800358_42187036_5237378_n.jpg "," delete_type ":" DELETE "," upload_type ":" video_montage "}]  < / Pre> 

I would like to get the value that is in upload_type and some actions based on that Please, but I'm not sure how to get it from my function

thanks

Data.result is an array, you need access to the first element and then go to upload_type .

Try console.log (data.result [0] .upload_type);

Update: If the data is a string, then you need to parse it first. / P>

  var results = JSON.parse (data.result); Console.log (Results [0] .upload_type);    

Comments