Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Jquery使用XML更新Div_Jquery_Xml - Fatal编程技术网

使用Jquery使用XML更新Div

使用Jquery使用XML更新Div,jquery,xml,Jquery,Xml,全部, 我知道这很愚蠢很简单但是 我正在使用jQuery。我得到了这样一个XML文档 $.ajax({ type: verb, url: url, dataType: datatype, success: callback }) } 在我的回调中,我想用结果更新名为ID=“UpdateMe”的div,使其看起来像格式良好的XML 这是我用来显示结果的psudeo代码 function update_me_with_response(data){ //I mak

全部,

我知道这很愚蠢很简单但是

我正在使用jQuery。我得到了这样一个XML文档

$.ajax({
   type: verb,
   url: url,
   dataType: datatype,
   success: callback
   })
}
在我的回调中,我想用结果更新名为ID=“UpdateMe”的div,使其看起来像格式良好的XML

这是我用来显示结果的psudeo代码

function update_me_with_response(data){
  //I make it here just fine with no problems.
  //The following line is totally not working any ideas?  
      $("#ajaxer_output").text(data.text.escapeHTML());
   }
试一试


.text()和.html()之间的区别在于.text会转义发送进来的任何html。所以您可以只使用.text()


我假设您正在将html/xml作为响应返回,并希望在页面上显示html/xml(包括所有尖括号和标记)?

如果您希望显示带有标记的xml,请尝试以下操作:

function update_me_with_response(data){
    $("#ajaxer_output").html(data.replace(/</g, '&lt;'));
}
使用响应(数据)更新函数{
$(“#ajaxer_output”).html(data.replace(/Try

function update_me_with_response(data){
    $("#ajaxer_output").html(data.replace(/</g, '&lt;'));
}
$("#ajaxer_output").text(data.xml);