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

浏览:1088 发布日期:2015/07/31 分类:求助交流 关键字: ThinkPHP AJAX
/**控制器*/
public function test11()
{
$province = $_POST['province'];
$info = "<city>湖南</city><city>益阳</city>";
$this -> ajaxReturn($info,'xml');
}
/** JS*/
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);
}
}
最佳答案
评论() 相关
后面还有条评论,点击查看>>