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 JP开发者_如何学JAVAG, 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;
}
精彩评论