duan02143 2011-02-11 20:38
浏览 47
已采纳

Jquery ajax响应文本未完成

I have a page in which I have to reload latitudes and longitudes to refresh a Google map. I do this using ajax, the JS function is this:

function refreshMap(idCamiones)
{

$.ajax({
    type: "GET",
    async: false,
    url: "refresh.php",
    data: "idCamiones="+idCamiones,
    contentType: "application/x-www-form-urlencoded",
    success : function(text)
        {
             refresh = text;
         }
});

//Borramos todos los marcadores actuales
for (i in markersArray) {markersArray[i].setMap(null);}
markersArray.length=0;

//generamos un array con las latitudes en pares y las longitudes en nones.
posArray=refresh.split(",");
for(i=0;i<=posArray.length;i=i+2)
{
addMarker(2,posArray[i],posArray[i+1]);
}
}

refresh is a global JS variable which stores the response from the PHP file. If I call the PHP file using the browser the data is complete, I'm supossed to get (posArrray[0],..,posArray[n]) but if I call the PHP using the JS function the JS variable only saves (posArray[n-1],posArray[n]) and all the other coordinates are missing just in the JS variable my PHP script works well.

<?php
include_once("conexion.php");
$idCamiones=$_GET['idCamiones'];
$reponse='';
$query="SELECT * from datos INNER JOIN dbo.eventos ON eventos.codigo=datos.codigo where id IN (
Select max(id) from datos where camion in (".$idCamiones.") group by serie)  order by serie";
$bD=new COM("ADODB.Recordset");
$bD->Open($query,$conn);
$busData=fetch_assoc($bD);
$bD->close();
for($i=0;$i<sizeof($busData);$i++)
{
$response.=$busData[$i]['latitud'].",".$busData[$i]['longitud'].",";
}
    echo $response;

?>

I dont know if I'm returning the $response in the php file incorrectly, I also tried with refresh=$.ajax({}).responseText; and I get the same results.

  • 写回答

3条回答 默认 最新

  • drwo2014 2011-02-11 21:40
    关注

    Call your AJAX url+parameters directly in your browser's address bar and see what the response it.

    If you have FF and Firebug, you can use the NET -> XHR tab to inspect the request and the response directly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题