求解TP框架Ajax怎么接受XML数据。。。

浏览:648 发布日期:2015/07/31 分类:求助交流 关键字: Ajax
控制器:
/**
* @desc 测试2 获取数据
*/
public function test11()
{
$province = $_POST['province'];
$info = "<city>湖南</city><city>益阳</city>";
$this -> ajaxReturn($info,'xml');
}

ajax:

function getCity()
{
xmlHttp = GetxmlHttpobject();

if(xmlHttp)
{
var url = "{$smarty.const.__CONTROLLER__}/test11";
var data = "province="+$('province').value;
xmlHttp.open("post",url,true);
xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function()
{
if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
alert(xmlHttp.responsexml.getElementsByTagName("city").length);
}
};
xmlHttp.send(data);
}
}

onchange(getCity())事件的时候,弹出的长度总是0,试了几种方法都不行,不知道为什么,求大神指点指点。。。。
最佳答案
评论() 相关
后面还有条评论,点击查看>>