JavaScript encapsulates AJAX-passed data code _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

var parambeanlist = new Array ();
Array.prototype.addparambean=function (parambeanobj) {
var index = This.containparambean (parambeanobj);
if (index!=-1) {
This[index] = parambeanobj;
} else {
This.push (Parambeanobj);
}
};
Array.prototype.clear=function () {
if (This.length = = 0) {
Return
}
For (var index in this) {
This.pop ();
}
};
Array.prototype.containparambean=function (parambeanobj) {
var index =-1;
if (This.length = = 0) {
return index;
}
for (var tempindex = 0, step = this.length; Tempindex < step; tempindex++) {
if (This[tempindex].compare (parambeanobj) = = 0) {
index = Tempindex;
Break
}
}
return index;
};
var Parambean = new Function (Pkcode, opdate, value) {
This.pkcode = Pkcode;
This.opdate = opdate;
This.value = value;
};
parambean.prototype={
Tostring:function () {
Return "[Pkcode:" + This.pkcode + ", opdate:" + this.opdate + ", Value:" + This.value + "]";
},
Doverify:function () {
Return (This.pkcode this.opdate this.value?) ' True ': ' false ': ' False ': ' false ';
},
Compare:function (otherobj) {
var result =-1;
if (otherobj) {
if (This.pkcode = = Otherobj.pkcode && This.opdate = = Otherobj.opdate
&& This.value = = Otherobj.value) {
result = 0;
}
}
return result;
}
};
var paramutils = new Object ();
Paramutils.docreateajaxstr=function () {
var paramstr = "";
if (Parambeanlist.length = = 0) {
return paramstr;
}
var keyparamarray = new Array ();
var valueparamarray = new Array ();
for (var index = 0, step = parambeanlist.length Index < step; index++) {
var tempobj = Parambeanlist[index];
Keyparamarray.push (Tempobj.pkcode + "'" + tempobj.opdate);
Valueparamarray.push (Tempobj.value);
}
Paramstr = "key_param=". Concat (encodeURIComponent (Keyparamarray.join (",")). Concat ("&"). Concat ("value_param= ". Concat (encodeURIComponent (Valueparamarray.join (", ")));
return paramstr;
};

This article I wrote for a while, to the csdn on a half-day to get up, I use IE6 cut to the senior editor, the content is directly empty, and finally with Firefox browser unexpectedly brought up again.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.