正文
1.最简介写法
function AjaxDepotGoods(id){ $.ajax({ url: success:function(html){ $().html(html) } }); }2.进阶写法
$.ajax({ url:, type: , data:{ success:function (html){alert(html); }, error:function(){ alert('查询错误') } })3.json返回数据
php 输出代码
{:,:24}js代码
$.ajax({ url:, type: , data:{:$keywords}, dataType: , success:function ({alert(html.name); })
4.【高级json】php,ajax,json 返回的json是多维数组
php输出的代码
[{:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,::},{:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,::},{:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,::},{:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,:,::}]js代码
json个数: (html.length)
$.ajax({ url:, type: , data:{:$keywords}, dataType: , success:function (html){ $str = ; for(i=0;i<html.length;i++){ $str += ; $str +=+html[i][]+; $str +=+html[i][]+; $str +=+html[i][]+; $str +=+html[i][]+; $str +=; } $str += $().html($str); //alert(html[0]['goods_id']); }, error:function(){ $str = ; $str += ; $str +=; $str += ; $str += $().html($str); } })