You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanted to use your plugin at some other plugin I was making, so I took the liberty of fixing the script to allow support for arrays, objects and strings:
Just replace where it says:
// If there is any additional data specified via the `data` option,// we add it as hidden fields to the form. This (currently) requires// the `processData` option to be set to false so that the data doesn't// get serialized to a string.if(typeof(options.data)==="string"&&options.data.length>0){$.error("data must not be serialized");}$.each(options.data||{},function(name,value){if($.isPlainObject(value)){name=value.name;value=value.value;}$("<input type='hidden' />").attr({name: name,value: value}).appendTo(form);});
With the following:
// Convert data to string, if not already a stringif(options.data&&options.processData&&typeofoptions.data!=="string"){options.data=jQuery.param(options.data,options.traditional);}// Convert string to file inputs to be submitted to the iframe// Split string by "&"varsplitString=decodeURIComponent(options.data).split("&");for(vari=0;i<splitString.length;i++){// Split substing by "="varkeyValuePair=splitString[i].split("=");// Create input field with name and value of split string$("<input type='hidden' />").attr({name: keyValuePair[0],value: keyValuePair[1]}).appendTo(form);}
Please add this to the actual plugin!
Also use the fix mentioned on another issue, so that data are submitted in jQuery 1.7+!
The text was updated successfully, but these errors were encountered:
I've also run into this problem and spent hours pulling my hair out. The problem with trying to fix it on my end is that my data is being set by an ajaxPreFilter. And ajaxPreFilters ONLY allow setting data to a string. You can see the "wontfix" bug report on jQuery here: http://bugs.jquery.com/ticket/9757
That means that this needs to be fixed in iframe-transport.
The above code has an issue with form field values containing = characters. Here's my adapted version:
// Convert data to string, if not already a stringif(options.data&&options.processData&&typeofoptions.data!=="string"){options.data=jQuery.param(options.data,options.traditional);}// Convert string to file inputs to be submitted to the iframe// Split string by "&"varsplitString=options.data.split("&");for(vari=0;i<splitString.length;i++){// Split substing by "="varkeyValuePair=splitString[i].split("=");// Create input field with name and value of split string$("<input type='hidden' />").attr({name: decodeURIComponent(keyValuePair[0]),value: decodeURIComponent(keyValuePair[1])}).appendTo(form);}
I wanted to use your plugin at some other plugin I was making, so I took the liberty of fixing the script to allow support for arrays, objects and strings:
Just replace where it says:
With the following:
Please add this to the actual plugin!
Also use the fix mentioned on another issue, so that data are submitted in jQuery 1.7+!
The text was updated successfully, but these errors were encountered: