jQuery ajax

jQuery ajax

Posted by Lv Hui on May 10, 2014

jQuery中发送ajax请求

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$(function(){
	$.ajax({
		url:'receive.php', //数据发送地址
		type: 'post', //数据传输方式
		data:{menu:1}, //需要传送的数据
		dataType:'json', //返回的数据格式
		success:function(data){ //成功接收到数据执行的函数
			//遍历数组
			$.each(data,function(k,v){
				//重组数据分配到页面
				var str = '<p>'+v.text+'</p>';
				$('#box').append(str);
			})
		}
	})
})