views:

29

answers:

2

I am quite new to Javascript. I am trying to use the ajaxupload plugin to make an upload work within a form. I figured out how to use the form with the file upload plugin. Now, however the output of the form field just appears as [object Object].

Here's the code

 var text=$('input#text').val();


     onSubmit: function(file, ext){
          if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){ 
                         // extension is not allowed 
          status.text('Only JPG, PNG or GIF files are allowed');
          return false;
         }
         status.text('Uploading...');
         this.setData({'text': text});
A: 

is the "text" the id name of the input box?

Martin Ongtangco
Yes! It is the id name of the input box
Udit Agarwal
I would really appreciate it if you could help me with this.
Udit Agarwal
are you sure you're using an <input> object?
Martin Ongtangco
Yes, I am using an <input type="text" id="text" name="text"></input>
Udit Agarwal
i would suggest you rename the ID to something unique like txtName or something.
Martin Ongtangco
A: 

You need to return false always. You did not post the complete code, but something like this

onSubmit: function(file, ext){
  if (ext && /^(jpg|png|jpeg|gif)$/.test(ext)) { // extension is allowed 
    status.text('Uploading...');
    this.setData({'text': text});
  }
  else {
    status.text('Only JPG, PNG or GIF files are allowed');
  }  
  return false;
}
mplungjan