我用ajax发送到php页面上一个请求如下:function refreshGoodsCat() {
var goods_type = document.getElementById("goods_type").value;
if (goods_type == "\u8bf7\u9009\u62e9...") {
clearGoodsCat();
clearBabyGoods();
}
var url = "index.php?" + createOnlyString(goods_type) + "&ts=" + new Date().getTime();
createXMLHttpRequest();
xmlHttp.onreadystatechange = handleGoodsCatChange;
xmlHttp.open("GET", url);
xmlHttp.send(null);
}在php处理,返回得到的响应内容,这个响应的内容要如何发送给ajax.
我想在ajax里面用xmlHttp.responseText接收

解决方案 »

  1.   

    在php页面里直接echo xml or json字符串,客户端收到后解析xml or json, xml可以使用msxml组件解析,json可以下载json2.js解析。不过我建议ajax还是使用jquery提供的ajax函数,可以支持多浏览器,php使用json,php支持json。
    我写过一个类似.net ICallbackEventHandler的小框架,需要我可以发给你,基于jquery and json2.
      

  2.   

    我不懂json啊,只是我现在用responseText却返回整个html的代码。
    这是怎么回事啊,郁闷死了。。
      

  3.   

    相应的页面根据条件返回内容:if($have){
    echo "1";
    exit();AJAX接收之后再根据返回的内容判断并提示:
    if(xmlHttp.responseText=="0"){
    alert('投票成功,谢谢您的参与!');
    return false;
    }else if(xmlHttp.responseText=="1"){
    alert('对不起,你只能对此文投一次票!');
    return false;
    }
      

  4.   

    php json 很简单,json_encode,json_decode,需要开启json扩展库,google一下就都知道了。