Source: http://www.verydemo.com/demo_c110_i18421.html
<script language="javascript" src="http://www.nowamagic.net/zt/access_count/js/jquery-1.4.2.min.js"></script> <script language="javascript" src="http://www.nowamagic.net/zt/access_count/js/jquery.jsonp-2.1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ insert_vote(); }) function insert_vote(){ var j = null; $.ajax({ type:'get', url:'http://www.nowamagic.net/zt/access_count/jsonp.php', dataType:'jsonp', jsonp:"callback", data:{"a":"insert", "type":"aa", "time":"bb", "id":"dd", "allowVote":"cc"}, async: false, success:function(data){ j = data; //alert("1"); alert(j.title); } }) } function init(){ $.ajax({ dataType: 'jsonp', data: 'id=10', jsonp: 'jsonp_callback', url: 'http://www.nowamagic.net/zt/access_count/jsonp.php', success: function () { // do stuff alert(jsonp.respond); }, }); } function init2(){ $.ajax({ async:false, url: 'http://www.nowamagic.net/zt/access_count/jsonp.php', // 跨域URL type: 'GET', dataType: 'jsonp', jsonp: 'jsoncallback', // default callback data: 'id=10', // request data timeout: 5000 , beforeSend: function (){ // This method is not triggered in jsonp mode. The reason may be that if dataType is specified as jsonp, it is no longer an ajax event }, success: function (json) { // The callback function pre-defined by jquery on the client side, after successfully obtaining the json data on the cross-domain server, the callback function will be dynamically executed alert(json.respond.title); if (json.actionErrors .length!=0 ) { alert(json.actionErrors); } }, complete: function(XMLHttpRequest, textStatus){ }, error: function (xhr){ // This method is not triggered in jsonp mode. // Request error handling alert("Request error (please check the correlation network status.)" ); } }); } </script>