doudou7361 2012-05-18 15:01
浏览 49

jsonData为null错误一天运行正常到第二天发出此错误

I've done my php and jquery code to get data from mysql server and send this data to show that content.

here's the code

newsletter_mainframe.php

<?php
    //allow sessions to be passed so we can see if the user is logged in
    session_start();
    //connect to the database so we can check, edit, or insert data to our users table
    $con = mysql_connect('localhost', 'user', 'pwd') or die(mysql_error());
    $db = mysql_select_db('dbname', $con) or die(mysql_error());
    $SQL = "SELECT * FROM tablename";
    if(array_key_exists('rowcount', $_GET)) {
      $query = mysql_query("select count(*) as total FROM paperboy");
      $result = mysql_fetch_array($query);
      $json = array('rowCount' => $result); // can add more data here
      return json_encode($json);
    }
?>
<link rel="stylesheet" type="text/css" href="css/paperboy.css" />
<div id="rss_cabecera">
canal de noticias
</div>
<script type="text/javascript">
    function MuestraNoticia(str)
    {
    if (str=="")
      {
      document.getElementById("rss_rcpt").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("rss_rcpt").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","auth/peticion_noticia.php?page="+str,true);
    xmlhttp.send();
    }
    $.getJSON('newsletter_mainframe.php?rowcount', function(data) {
        var jsonData = $.parseJSON(data);
        var ntop = jsonData.rowCount * 250;
        $('#footer').css('top', ntop);
    });
    MuestraNoticia(1);
</script>
<div id="rss_rcpt">
</div>

auth/peticion_noticia.php

<?php
    $event=$_GET["page"];
    if($page == 1){

    //allow sessions to be passed so we can see if the user is logged in
    session_start();
    //connect to the database so we can check, edit, or insert data to our users table
    $con = mysql_connect('localhost', 'rsskill', '14789632qwerty') or die(mysql_error());
    $db = mysql_select_db('newsletter', $con) or die(mysql_error());
    $SQL = "SELECT * FROM paperboy";
    $result = mysql_query($SQL);
    echo "<style>.PaperPage {position:relative; left:0px; top:0px; width:920px; font-family: 'Ubuntu', sans-serif; font-size: 12px; color:green;}</style>";
    echo "<style>.PaperCabPage {padding-left:5px; height:30px; border:1px solid #99cc33; border-radius:10px; font-family: 'Ubuntu', sans-serif; font-size: 14px; background-color:#99cc33; color:#404040; font-weight:bold}</style>";
    echo "<style>.PaperFechaData:{background-color:#99cc33; color:white; font-family: 'Ubuntu', sans-serif; font-size: 14px; border:1px solid #99cc33; border-radius:10px}</style>";
    echo "<style>.PaperTitData {padding-left:10px; height:30px; border:1px solid white; border-radius:10px; font-family: 'Ubuntu', sans-serif; font-size: 14px; font-weight:bold; text-transform:uppercase; background-color:#99cc33; color:#404040}</style>";
    echo "<style>.PaperCabData {padding-left:5px; height:60px; border:0 none; font-family: 'Ubuntu', sans-serif; font-size:14px; font-weight:normal; text-transform:uppercase; text-align:justify; background-color:white; color:#404040}</style>";
    echo "<style>.PaperImgData {text-align:center; vertical-align:center; height:230px; width:240px; border:2px solid #99cc33; border-radius:10px; font-family: 'Ubuntu', sans-serif; font-size: 14px; background-color:white; color:#404040}</style>";
    echo "<style>.PaperTxtData {vertical-align:top; padding: 5px 5px 5px 5px; height:230px; border:2px solid #99cc33; border-radius:10px; font-family: 'Ubuntu', sans-serif; font-size: 12px; text-align: justify; background-color:white; color:#404040}</style>"; 
    echo "<table class='PaperPage'>";
    echo "<tr>";
    $GLOBALS['normalizeChars'] = array(
        'Á'=>'&Aacute;', 'É'=>'&Eacute;', 'Í'=>'&Iacute;', 'Ó'=>'&Oacute;', 'Ú'=>'&Uacute;', 'Ñ'=>'&Ntilde;',
        'á'=>'&aacute;', 'é'=>'&eacute;', 'í'=>'&iacute;', 'ó'=>'&oacute;', 'ú'=>'&uacute;', 'ñ'=>'&ntilde;'
    );
    function arregla($toClean){
        return strtr($toClean, $GLOBALS['normalizeChars']);
    }

    while ($row = mysql_fetch_array($result)) {
        arregla($row['contenido']);
        arregla($row['cabecera']);
        echo "<td colspan='2' class='PaperTitData' style='background: url(http://www.server.com/img/background.png) repeat-x top; width:910px'>" .$row['titulo']. "</td>";
        echo "</tr><tr>";
        echo "<td colspan='2' class='PaperCabData' style='width:920px'>" .$row['cabecera']. "</td>";
        echo "</tr><tr>";
        echo "<td class='PaperImgData' style='background: url(".$row['img'].") no-repeat center; width:240px'>&nbsp;</td>";
        echo "<td class='PaperTxtData' style='background: url(http://www.server.com/img/background.png) repeat-x top; width:650px'>" .$row['fecha']. "<br><br>" .$row['contenido']. "</td>";
        echo "</tr>";
        echo "<tr><td colspan='2'></td></tr>";
        echo "<tr><td colspan='2' style='border: 0px none'><br><br></td></tr>";
    }
    echo "</table>";
    mysql_close($con);
    } else {
        die();
    }   
?>

CONSOLE LOG RETURN: jsonData is null. This code was ok until today but now it return that error.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)