最近用一些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); }?>

 

相关文章:

  • 2021-08-19
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2021-11-29
  • 2021-07-06
  • 2021-09-14
  • 2022-12-23
猜你喜欢
  • 2021-12-06
  • 2021-10-04
  • 2022-12-23
  • 2021-11-14
  • 2021-05-02
  • 2022-12-23
  • 2021-08-21
相关资源
相似解决方案