jQuery中Ajax的細(xì)節(jié)設(shè)定$.ajax()

          function  createQueryString(){
              var firstName =  encodeURI(encodeURI($(#firstName).value));
              var query = "firstName="+firstName+"&secondName="+"Lee";
              return query;
          }

          function doRequestUsingGET(){
              $.ajax({
                  type:"GET",
                  url:"14.html",
                  data:createQueryString();
                  success:function(data){
                  $("#serverResponse").html(decodeURI(data));
                  }
              })
          }

          function doRequestUsingPOST(){
           $.ajax({
            type: "POST",
            url: "14-5.aspx",
            data: createQueryString(),
            success: function(data){
             $("#serverResponse").html(decodeURI(data));
            }
           });
          }


          function test(varWeight){
              //var index = parseFloat(document.activeElement.id);獲得當(dāng)前對(duì)象
              var index = parseFloat($(varWeight).attr("id"));//獲得當(dāng)前id內(nèi)容
             
             var fieldNo =  document.getElementById("fieldNo")[index].value;
               var weight =  document.getElementsByName("weight")[index+1].value;
              if(fieldNo != "" && weight != ""){
                 var query = "fieldNo="+fieldNo+"&weight="+weight;
                alert(query);
                   $.ajax({ 
                     type: "POST", 
                      url: '${webroot}/suggest!maxCount.do', 
                     // dataType: 'text', 
                      data: query, 
                      success:function(data){
                      //name1=msg.userName[0].name1;
                      //close();
                      //return false;
                      // document.getElementById(obj).innerHTML=html;
                      },
                      error: function(){  
                    //  document.getElementById(obj).innerHTML="網(wǎng)絡(luò)連接超時(shí),無法顯示數(shù)據(jù)!";  
                   //  return;  
                  }  
                     
                   });

              }
             
            
          }

          posted on 2012-05-17 11:29 youngturk 閱讀(256) 評(píng)論(0)  編輯  收藏 所屬分類: Ajax

          <2012年5月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          導(dǎo)航

          統(tǒng)計(jì)

          公告

          this year :
          1 jQuery
          2 freemarker
          3 框架結(jié)構(gòu)
          4 口語(yǔ)英語(yǔ)

          常用鏈接

          留言簿(6)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          相冊(cè)

          EJB學(xué)習(xí)

          Flex學(xué)習(xí)

          learn English

          oracle

          spring MVC web service

          SQL

          Struts

          生活保健

          解析文件

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 北宁市| 维西| 高邮市| 定南县| 玛纳斯县| 溆浦县| 泽库县| 甘德县| 南昌县| 屯门区| 获嘉县| 武义县| 北海市| 宜黄县| 壶关县| 敦化市| 唐河县| 乌苏市| 景洪市| 墨竹工卡县| 高青县| 怀来县| 新和县| 博白县| 无锡市| 宽甸| 天峨县| 门源| 黄梅县| 盘锦市| 邻水| 苍梧县| 金昌市| 仁化县| 娄底市| 合作市| 阿尔山市| 色达县| 比如县| 阳泉市| 合肥市|