js在ajax中的数据处理

00、eval转换对象

        if ($.type(data) == 'string')
        {
            data=data.replace(/\s/ig, ' ');
            return eval('(' + data + ')');
        }   

00、序列化表单

        json格式: data:$form.serializeArray();

        字符串方式:$form.serialize;

00、字符串拼接

      1.html=''+
                '<td>表格</td>'+
                '<td id=" '+iterm.value+' ">'+iterm.anwser+'</td>';
        2、事件传参  

<!--<a οnmοuseοver="onMouseOverbox2('an_e91c6f66b00840b4963c0415e3aee274',

                                                                   'ae91c6f66b00840b4963c0415e3aee274_0',this);">

          查看

 </a>-->
        '<a οnmοuseοver="onMouseOverbox2(\' an_ '+questionid+' \',

                                                                      \' a '+questionid+' _ '+index+' \',this);">'+  

          '查看</a>'

00、数据循环

result1=[{"addflag":false,"anwser":"d,d","anwser_result":"0","anwser_time":"2013-03-21","history_id":"6334148648eb40298f67fd16c5ea427a","id":"50a6e441a501435595720377b2d72f69","question_id":"f7ad50d52d48480ca21d3be32d4022a0","scores":0,"seq_no":3,"showAll":true,"std_area_id":"3","std_id":"03010701","std_name":"达芬奇","tch_id":"","tch_name":"","tch_scores":0,"tch_suggestion":"","tch_time":"","uncertain_flag":"0"},      {"addflag":false,"anwser":"1,1","anwser_result":"0","anwser_time":"2013-03-21","history_id":"0cf2a2ae37be46eeb19ad505db42d726","id":"a09223db67b5443cabbe928909610286","question_id":"f7ad50d52d48480ca21d3be32d4022a0","scores":0,"seq_no":2,"showAll":true,"std_area_id":"3","std_id":"03010701","std_name":"达芬奇","tch_id":"","tch_name":"","tch_scores":0,"tch_suggestion":"","tch_time":"","uncertain_flag":"0"}]
result2=[{ "addflag":false,   "anwser":"<p>\r\n\t1<\/p>\r\n","anwser_result":"0",
      "anwser_time":"2013-03-21",   "history_id":"0cf2a2ae37be46eeb19ad505db42d726",
      "id":"a1f03bb16dfa44e09fe9a43b1d8cca4e",    "question_id":"fd4b3956a14244d8a9f10e0fa536792d",
      "scores":0,"seq_no":1,    "showAll":false,    "std_area_id":"3",
      "std_id":"03010701",    "std_name":"达芬奇",    "tch_id":"",
      "tch_name":"",    "tch_scores":0,
      "tch_suggestion":"",    "tch_time":"",
      "uncertain_flag":"0"}]
questionid='Action 私有属性';

 

result=eval('(' + result + ')');
$.each(result,function(index,iterm){
     if(iterm.showAll){
	 html=html+'<tr>'+
              '<td>'+iterm.anwser_time+'</td>'+
              '<td id="a'+questionid+'_'+index+'">'+iterm.anwser+'</td>'
              '</tr>';
     }

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值