Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 没有返回Ajax调用_Php_Jquery_Odbc_Ms Access 2007 - Fatal编程技术网

Php 没有返回Ajax调用

Php 没有返回Ajax调用,php,jquery,odbc,ms-access-2007,Php,Jquery,Odbc,Ms Access 2007,问题是PHP文件没有发送回数据,或者JS文件没有捕获数据 确切的问题是数据没有显示在中的index.php页面上。 我在getDetails.php文件中包含了代码来记录它在做什么。它允许我看到查询正在运行,数据正在返回 我在过去使用过类似的代码,没有任何问题。唯一的区别是前面的代码使用的是MySQL。这段代码处理的是Access数据库。我不知道是否需要对json_编码做一些特殊的处理来处理访问数据 我在java.js的开头使用了一个alert(),以确保调用了java代码。它是。永远不会调用d

问题是PHP文件没有发送回数据,或者JS文件没有捕获数据

确切的问题是数据没有显示在
中的index.php页面上。 我在getDetails.php文件中包含了代码来记录它在做什么。它允许我看到查询正在运行,数据正在返回

我在过去使用过类似的代码,没有任何问题。唯一的区别是前面的代码使用的是MySQL。这段代码处理的是Access数据库。我不知道是否需要对json_编码做一些特殊的处理来处理访问数据

我在java.js的开头使用了一个
alert()
,以确保调用了java代码。它是。永远不会调用
details=result
命令后面的警报

INDEX.PHP:

<!doctype html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/plain; charset=UTF-8"/>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
        <script src="java.js" type="text/javascript"></script>
    </head>
    <body>
        <div id="reportDetails" class="reportDetails" align=center></div>
    </body>
<html>

JAVA.JS:

jQuery(document).ready(function () {
    var ra='7100913063';
    $.ajax({
        type: 'POST',
        url: 'getDetails.php',
        data: 'value=' + ra,
        dataType: 'json',
        cache: false,
        success: function(result) {
            details = result;
            $("#reportDetails").text("");
            for (var i = 0; i < details.length; i++) {
                $("#reportDetails").append("<tr class='bottom'><td width=200 align=center class='bottom'>" + details[i][0] + "</td><td width=200 align=center class='bottom'>" + details[i][1] + "</td><td width=200 align=center  class='bottom'> " + details[i][2] +"</td></td><td width=200 align=center  class='bottom'> " + details[i][3] +"</td></td></tr>");
            }
            $("#reportDetails").append("</table>");
        },
    });
});
jQuery(文档).ready(函数(){
var ra='7100913063';
$.ajax({
键入:“POST”,
url:'getDetails.php',
数据:“值=”+ra,
数据类型:“json”,
cache:false,
成功:功能(结果){
细节=结果;
$(“#报告详情”)。文本(“”);
对于(变量i=0;i
getDetails.php

<?php
include("../../scripts/adodb/adodb.inc.php");

$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");

$ra = $_POST['value'];
set_time_limit(0);
date_default_timezone_set('America/Chicago');                                       
$counter = 0;

$connect = odbc_connect("Driver={Microsoft Access Driver (*.mdb)};Dbq=//server/directory/database.mdb", '', '');
$query = "SELECT distinct ra, MIN(received) as startDate, MAX(completion) AS stopDate, MAX(status) as stat FROM cont WHERE ra = '" . $ra . "' GROUP BY ra";
$result = odbc_exec($connect,$query);

while(odbc_fetch_row($result)){
    $radetails[0] = odbc_result($result,"ra");
    fwrite($fh, $radetails[0]);
    $radetails[1] = odbc_result($result,"startDate");
    fwrite($fh, $radetails[1]);
    $radetails[2] = odbc_result($result,"stopDate");
    fwrite($fh, $radetails[2]);
    $radetails[3] = odbc_result($result,"stat");
    fwrite($fh, $radetails[3]);
}
fclose($fh);
echo json_encode($radetails);
?>

我的getDetails.php中有一行
“echo
。删除了那一行,现在就可以使用了。

我的getDetails.php中有一行
“echo
。删除了这一行,现在就可以工作了。

在那里抛出一个ajax故障处理程序,看看是否会/什么会回来?另外,您是否尝试过调试“java.js”并查看“success”会发生什么情况?如果它执行的话?控制台日志中有任何内容吗?很可能您的php没有返回json。您是否在浏览器控制台中查找错误?这应该能准确地告诉你问题出在哪里。Firebug告诉你什么是被发送和返回的?调试AJAX blind没有用如果您使用的是Firefox,请尝试使用Firebug。查看console选项卡,然后单击…[url]…getDetails.php,最后单击Response选项卡。这将显示返回的内容。在其中抛出一个ajax失败处理程序,看看是否返回/返回了什么,怎么样?另外,您是否尝试过调试“java.js”并查看“success”会发生什么情况?如果它执行的话?控制台日志中有任何内容吗?很可能您的php没有返回json。您是否在浏览器控制台中查找错误?这应该能准确地告诉你问题出在哪里。Firebug告诉你什么是被发送和返回的?调试AJAX blind没有用如果您使用的是Firefox,请尝试使用Firebug。查看console选项卡,然后单击…[url]…getDetails.php,最后单击Response选项卡。这将显示返回的内容。