Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created March 18, 2015 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save divinity76/be5d4bbd05f48c1bb55e to your computer and use it in GitHub Desktop.
Save divinity76/be5d4bbd05f48c1bb55e to your computer and use it in GitHub Desktop.
function MyFormData(){
var data=[];
this.append=function append(name,value){
data.push([name.toString(),value.toString()]);
};
this.toString=function toString(){
var ret="";
encodeURIComponent
var i=0;
for(;i<data.length;++i){
ret+=encodeURIComponent(data[i][0])+"="+encodeURIComponent(data[i][1])+"&";
}
if(data.length>0){
ret=ret.slice(0,-1);
}
return ret;
};
this.valueOf=function valueOf(){
return this.toString();
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment