javascript - JQuery, Ajax and PHP : Sending FormData AND String values -


i'd send php page formdata value , string values.

here's code on js side:

$.ajax({             url: 'upload-pic.php',              type: 'post',             data: {                 type : type,                 id : id,                 formdata : formdata             },             processdata:false,             success: function(data, status) {                  //stuff i'm doing data               }         });  

and on php side :

if(isset($_post['type']) && isset($_post['id'])){     //stuff i'm doing } 

then, error saying type , id not set. i'm guessing comes processdata: false ajax call. without this, inevitable illegal invocation, coming trying send formdata.

is there way send formdata , string values on same call ?

thanks!

i assume using formdata object, in case need append string values formdata object, , pass object in data parameter in jquery's $.ajax.

you can append data formdata object, method append.

this should work:

formdata.append('type', type); fromdata.append('id', id); $.ajax({     url: 'upload-pic.php',      type: 'post',     data: formdata,     processdata:false,     contenttype: false,     success: function(data, status) {          //stuff i'm doing data      } });  

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -