jquery中ajax使用

JQuery的Ajax操作,对JavaScript底层Ajax操作进行了封装,

<script type="text/javascript">
	$.ajax({
            url:"url",   //上传地址
            type:"get",	 //上传方式
            dataType:"json",  //数据类型
            data:{
                userID:"001"  //具体数据
            },
            success:function(response){
            	// 成功回调函数
            },
            error:function() {
            	// 错误函数
            }
        });
</script>

  当然可以有简写的方式

$.get(
            "url",
            {userID:"001"},
            function(response) {
            }
        )

  或者

$.post(
            "url",
            {userID:"123"},
            function(response) {

            }
        )

猜你喜欢

转载自www.cnblogs.com/yuwen1995/p/9185167.html
今日推荐