blueimp/jQuery-File-Upload — Issue #1023: Send dynamic ajax value to formData
Author: Chekelin
Created: 2012-02-17 00:42:25+00:00
State: open

Hello If somebody could help me I would be eternally grateful.

My problem is this.

I have this code to send a form for saving in a DB

```javascript
$.ajax({
url : '/modules/forms.php',
type : 'POST',
dataType : 'JSON',
data : {
table : 'users',
validate : {
password : { encrypt : true },
confirmPassword : { ignore : true },
archivos : { ignore : true },
seccion : { ignore : true }
},
form : values
},
success : function(data){
insert_id = data.insert_id;
$('button.start').click();
}
});
```

The ajax send me back a json which I need only one var for sending to the uploader (data.insert_id). I don't know how to send that var via formData option in the uploader. This is what I have in the application.js

```javascript
var form = $('form').attr('data-form');

$("#"+form+"-form").fileupload({
url : '/ajax/uploader.php'
});

//Settings
$("#"+form+"-form").fileupload('option',{
maxFileSize : 4000000,
minFileSize : 10000,
acceptFileTypes : /(\.|\/)(gif|jpe?g|png)$/i,
previewMaxHeight: 180,
previewMaxWidth : 180,
previewAsCanvas : false,
paramName : 'archivos[]',
//formData : { record : insert_id },
start : function(){
$('img.loader').css('display', 'inline');
$('.preview img').css('opacity', '0.8');
},
stop : function(){
$('.preview img').css('opacity', '1');
}
});
```
The problem is that I can't send all the data (the form data) to the same script for processing it (uploader.php or whatever script)

Anybody can help me to send the hell var to the script?