简体   繁体   English

使用变量值时遇到问题

[英]Trouble with Using Value of a Variable

I am quite new to Javascript. 我对Java很陌生。 I am trying to use the ajaxupload plugin to make an upload work within a form. 我正在尝试使用ajaxupload插件在表单中进行上载工作。 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]. 现在,表单字段的输出仅显示为[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. 您需要始终返回false。 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;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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