码迷,mamicode.com
首页 > Web开发 > 详细

AJAX

时间:2016-03-14 13:46:20      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:

1、使用 .ajax

<script type="text/javascript">

$(function(){

         $( "#obj1" ).autocomplete({

                   source: "__CONTROLLER__/search",

                   minLength: 2,

                   autoFocus: true

         });

});

function GetUserValues()

{

         var company=$("#obj1").val();

         var action=‘getinfo‘;

         var para= {company:company,action:action};

         var url = "Data/index"; 

         $.ajax({ 

         type: "get", 

         url: url, 

         dataType: "json",  

         data: para, 

         success: function(msg){

                   //alert(msg);

                   $("#obj2").val(msg.company2);

                   $("#obj3").val(msg.company3);

                  $("#obj4").val(msg.company4);

                   $("#obj5").val(msg.linkman);

                   $("#obj6").val(msg.mobile);             

                   $("#obj9").val(msg.city);         

         } 

         });            

}

</script>

<input type="text" class="inpt1" name="obj1" id="obj1" onblur="return GetUserValues();" /> <small>*</small>   

 

2、使用 .post

<script type="text/javascript">

    function call_js()

    {

        var score=0 ;

        var itemID = {$data.id};

        ok();

        score = $("#my_score").val();      

        //alert("my score = "+score);

        $.post("__CONTROLLER__/saveexam",{itemID:itemID,score:score}, 

            function(data){

            //alert(data);

                if(data=="error"){       

                    alert(‘考试成绩保存失败,请联系管理员‘);   

                }    

            });

    }

</script>

<span id="submit_box"><img src="__PUBLIC__/Images/home/bnt7.jpg" class="img2" onclick="call_js()" /></span>

AJAX

标签:

原文地址:http://www.cnblogs.com/xihong2014/p/5275227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!