简体   繁体   中英

Trouble with Using Value of a Variable

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});

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;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM