Javascript array # Join When Using ajax to transmit data, it is essential to transcode the passed characters. My implementation method is to save the data to a JS bean, place the JS bean in the array. When the transmission parameter is generated, the jsbean in the array is decomposed to obtain the corresponding attribute information and encode it ..
VaR parambeanlist = new array (); <br/> array. prototype. addparambean = function (parambeanobj) {<br/> var Index = This. containparambean (parambeanobj); <br/> If (index! =-1) {<br/> This [Index] = parambeanobj; <br/>}else {<br/> This. push (parambeanobj); <br/>}< br/>}; <br/> array. prototype. clear = function () {<br/> If (this. length = 0) {<br/> return; <br/>}< br/> for (VAR index in this) {<br/> This. pop (); <br/>}< br/>}; <br/> array. prototype. containparambean = function (parambeanobj) {<br/> var Index =-1; <br/> If (this. length = 0) {<br/> Return Index; <br/>}< br/> for (VA R tempindex = 0, step = This. length; tempindex <step; tempindex ++) {<br/> If (this [tempindex]. compare (parambeanobj) = 0) {<br/> Index = tempindex; <br/> break; <br/>}< br/> Return Index; <br/>}; <br/> var parambean = new function (pkcode, opdate, value) {<br/> This. pkcode = pkcode; <br/> This. opdate = opdate; <br/> This. value = value; <br/>}; <br/> parambean. prototype = {<br/> tostring: function () {<Br/> return "[pkcode:" + this. pkcode + ", opdate:" + this. opdate + ", value:" + this. value + "]"; <br/>}, <br/> doverify: function () {<br/> return (this. pkcode? This. opdate? This. value? "True": "false"); <br/>}, <br/> compare: function (otherobj) {<br/> var result =-1; <br/> If (otherobj) {<br/> If (this. pkcode = otherobj. pkcode & this. opdate = otherobj. opdate <br/> & this. value = otherobj. value) {<br/> result = 0; <br/>}< br/> return result; <br/>}< br/> }; <br/> var paramutils = new object (); <br/> paramutils. docreateajaxstr = function () {<br/> var paramstr = ""; <br/> If (parambeanlist. length = 0) {<br/> return paramstr; <br/>}< br/> var keyparamarray = new array (); <br/> var valueparamarray = new array (); <br/> for (VAR Index = 0, step = parambeanlist. length; index <step; index ++) {<br/> var tempobj = parambeanlist [Index]; <br/> keyparamarray. push (tempobj. pkcode + "'" + tempobj. opdate); <br/> valueparamarray. push (tempobj. value); <br/>}< br/> paramstr = "key_param = ". concat (encodeuricomponent (keyparamarray. join (","))). concat ("&"). concat ("value_param = ". concat (encodeuricomponent (valueparamarray. join (","); <br/> return paramstr; <br/> }; After writing this article for a while, I couldn't mention it for a long time on csdn. I switched to advanced editing using IE6, and the content was blank. Finally, I used the Firefox browser to bring it up again ..