Send value on onsubmit
I want to send document.getEleme开发者_开发问答ntById('source').value
onsubmit. How can i send? thanks
this value document.getElementById('source').value
working fine. But I want to call this on submit. Because some time user could change the value.
new AjaxUpload(btnUpload, {
action: 'upload-file.php?source='+document.getElementById('source').value+'&destination='+document.getElementById('destination').value+'&subjectarea='+document.getElementById('subjectarea').value+'&order_id='+document.getElementById('order_id').value,
name: 'uploadfile',
onSubmit: function(file, ext,source){
if (! (ext && /^(txt|pdf|doc|docx|pptx|ppt|xlsx|xls)$/.test(ext))){
// extension is not allowed
status.text('Only TXT, PDF, PPTX, PPT, XLS, XLSX, DOC or DOCX files are allowed');
return false;
}
;
status.text('Uploading...');
}
you should put it in an input type value and then in the server - use REquest["id"] to get the val
$.ajax({
url:upload-file.php',
data:{source:$('#source').val(),destination:$('destination').val(),subjectarea:$('#subjectarea').val(),order_id:$('#order_id').val()},
type:'post',
dataType:'text',
success:function(msg){
$('#div').html(msg);
},
error:function(){
// handle your error
}
});
here "data" is used to send the variable to requested file. you can get these variable in your requested file by using $_POST[] OR $_REQUEST[] variable.
So name of the variable would be $_POST['source'], $_POST['destination'] and so on
精彩评论