HTML代码:
<script><br /> (function($){<br /> $.fn.RichmondJson = function(ajaxDiv)<br /> {<br /> $.ajax({<br /> url : 'data.php',<br /> type : 'get',<br /> dataType : 'json',<br /> data : {'inajax':1},<br /> timeout : 3000,<br /> cache : false,<br /> complete : function(){},<br /> success : function(data)<br /> {<br /> var s = '';<br /> $.each(data,function()<br /> {<br /> s += '<p>姓名:'+this.name+' 昵称:'+this.nick+'</script>
';});
$(s).appendTo('#'+ajaxDiv);
}
});
}
})(jQuery);
<script><br /> function Richmond()<br /> {<br /> var rm = new Object;<br /> rm.loaded = false;<br /> rm.json = function()<br /> {<br /> if(!rm.loaded)<br /> {<br /> jQuery(this).RichmondJson.apply(this,arguments);<br /> rm.loaded = !rm.loaded;<br /> }<br /> else<br /> {<br /> alert('无需重复加载!');<br /> return false;<br /> }<br /> }</script>
return rm;
}
var myobj = new Richmond();
jQuery框架AJAX返回JSON数据
JSON
PHP代码:
if($_GET['inajax'])
{
$arr = array(
array('name' => 'Richmond', 'nick' => iconv('gbk','utf-8','财富星空')),
array('name' => '343548', 'nick' => iconv('gbk','utf-8','笨笨草')),
array('name' => 'iceblue', 'nick' => iconv('gbk','utf-8','冰蓝'))
);
$json_string = json_encode($arr);
echo $json_string;
//echo '
';
//$obj = json_decode($json_string,true);
//print_r($obj);
}
?>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools