douwuying4709 2013-03-25 13:02
浏览 236

AJAX XMLHttpRequest给出错误

I have to deploy an application writhed on php, it was developed using a wamp server (on win). Now I have to deploy it on a apache2 debian server. The application works on the developers PC using wamp but can't get it to work on the debian server.

The problem is that all the grids (jquery grids) loads contents using ajax

grid.jqGrid({
            datatype: "xml",
            url:'../Controladores/cPedidos.php?action=lpd',
            mtype: 'POST',
            colNames:['FECHA','DEPOSITO','USUARIO'],
            colModel:[
                {name:'fecha_pedido',index:'fecha_pedido',width:120, sorttype: 'date'},
                {name:'deposito',index:'deposito',width:500, editable:false},
                {name:'usuario_id',index:'usuario_id',width:150, editable: false}
            ],
            rowNum:10,
            rowList:[10,20,40],
            pager: '#paginacion',
            gridview:true,
            rownumbers:true,
            ignoreCase:true,
            sortname: 'fecha_pedido',
            viewrecords: true,
            sortorder: "asc",
            caption:"Pedidos",
            height: "100%",
            subGrid : true,
            subGridUrl: '../Controladores/cPedidos.php?action=lad',
            subGridModel: [{ name  : ['Codigo','Cantidad','Articulo','Estado','Categoria','Observaciones'], 
                width : [50,50,450,60,60,150] }], 
            editurl: '../Controladores/cPedidos.php?action=editar',
            ondblClickRow: function(id, ri, ci) {
                // edit the row and save it on press "enter" key
                grid.jqGrid('editRow',id,true,null,null, 'clientArray');
            },
            onSelectRow: function(id) {
                if (id && id !== lastSel) {
                    // cancel editing of the previous selected row if it was in editing state.
                    // jqGrid hold intern savedRow array inside of jqGrid object,
                    // so it is safe to call restoreRow method with any id parameter
                    // if jqGrid not in editing state
                    if (typeof lastSel !== "undefined") {
                        grid.jqGrid('restoreRow',lastSel);
                    }
                    lastSel = id;
                }
            }
        }).jqGrid('navGrid','#pager',{add:false,edit:false},{},{},myDelOptions,{multipleSearch:true,overlay:false});
        //grid.jqGrid('filterToolbar',{defaultSearch:'cn',stringResult:true});
        $("#filtro").change(function(){
            var valor = $("#filtro").val();
            $("#tablapedidos").jqGrid().setGridParam({url:'../Controladores/cPedidos.php?action=lpd&filtro='+valor}).trigger('reloadGrid');
        });

The problem is that nothing is loaded, using firebug I get that the post to the url is aborted.

if I enter the url directly on the browser (ff) I get an "The connection was reset" error, Chrome:"Error 324 (net::ERR_EMPTY_RESPONSE)". if I do it on the localhost of the developers pc I get the XML file, the url page create the XML file using echo, example (not complete)

function getArticulosPendientes() {
if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
header("Content-type: application/xhtml+xml;charset=utf-8"); } else {
header("Content-type: text/xml;charset=utf-8");
}
$et = ">";
echo "<?xml version='1.0' encoding='utf-8'?$et
";
echo "<rows>";

$lista = getListaArticulosPendientes($_POST);
$resultado = array();

for($i = 0; $i < count($lista); $i++) {
    $fila = $lista[$i];
    $dif = diferenciaCompradoPedido($fila['item_id']);
    if($dif > 0) {
        $fila['cantidad'] = $dif;
        array_push($resultado, $fila);
    }
    else {
        array_push($resultado, $fila);
    }
}

for($a = 0; $a < count($resultado); $a++) {
    $row = $resultado[$a];
    $fecha = date("d/m/Y H:i", strtotime($row["fecha_pedido"]));
    echo "<row id='". $row["item_id"]."'>";
    echo "<cell>". $fecha."</cell>";
    echo "<cell>". $row["cantidad"]."</cell>";
    echo "<cell><![CDATA[". utf8_encode($row["descripcion"])."]]></cell>";
    echo "<cell><![CDATA[". $row["categoria"]."]]></cell>";
    echo "<cell><![CDATA[". $row["usuario_id"]."]]></cell>";
    echo "<cell><![CDATA[". $row["estado"]."]]></cell>";
    echo "<cell><![CDATA[". $row["observaciones"]."]]></cell>";
    echo "</row>";
}
echo "</rows>";

}

any ideas

  • 写回答

1条回答 默认 最新

  • douxi3977 2013-03-25 13:06
    关注

    You are using a relative path. Change path to absolute path like: http://www.yourdomain.com/folder/path/to/Controladores/cPedidos.php?action=lpd

    评论

报告相同问题?

悬赏问题

  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 arduino控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题