php中ajax调用出错的问题


最近用一些php,客户的使用jquery ajax的时候经常报错

ajax报错内容:readyState:4 status:"OK",statusText:"OK",或者undefined.

服务端返回数据是对的,百思不得其解。网上搜索了一番,最终总结一个用法出来。

客户端:ajax.html

$.ajax({
          url: 'tj.php',
          dataType: 'json',
              data: {fromid:'21',type:'query',sessionid:'12'},
          success: function(json){
              alert(json.share_app_times);
          },
          error: function(error) {
              alert.log("出错:"+JSON.stringify(error));            
          }
    });

服务端:tj.php

<?php
header("Content-Type: application/json; charset=utf-8");
$fromcid = $_GET['fromid'];
$type = $_GET['type'];$sessionid = $_GET['sessionid'];
if($type =="query"){
    $json = array('share_app_times' => 2,'share_timeline_times' => 1); echo json_encode($json); }?>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM