0

I have a jquery plugin that uses ajax to upload to the server. in the progress function I have logged the content of data to the console.

progress: function(e, data){
    console.log(data);
    if (data.result.status == 2) {
    //do something
    }
}

In the console I can see the result object that contains status and message.

enter image description here

If I try to access the status variable (data.result.status) I get the following error:-

TypeError: data.result is undefined
if (data.result.status == 2) {

Any ideas on what I'm doing wrong?

Regards

pjknight
  • 130
  • 3
  • 15
  • 2
    I know you've logged `console.log(data)` but on the off chance, It's not supposed to be `function(data, e){}`, is it? Also, which plugin is it? – Henrik Andersson Jun 11 '14 at 13:55
  • I second limelights - your arguments are turned around. Just see what ``` console.log(e, data); ``` gives you – Alexander Kludt Jun 11 '14 at 13:56
  • Can you post some code in jsFiddle? – SergeevDMS Jun 11 '14 at 13:57
  • Have a look at [console quirks](http://stackoverflow.com/q/23392111/1048572). Looks like they re-use the same `data` object. Try `console.log(data.result)` instead. – Bergi Jun 11 '14 at 13:57
  • plugin - http://tutorialzine.com/2013/05/mini-ajax-file-upload-form/ e does not contain the stuff I want console.lo(data.result) is undefined – pjknight Jun 11 '14 at 14:04

0 Answers0