我正在使用现代的jquery 1.5 ajax请求.到同一域的页面.我正在尝试使用油脂猴和jquery改进内部网站点的行为.
var jqxhr = $.ajax("anotherpage-response.html")
.success(function(data) {alert("cmp"); console.log(data);})
.error(function() { alert("error"); })
.complete(function() { alert("complete"); });
Run Code Online (Sandbox Code Playgroud)
它当前以字符串形式返回.任何想法我怎么能得到它作为一个dom像对象我可以使用jquery选择器进行返回???
我认为我喜欢的东西,fileType: html但它似乎不是ajax请求中的一个选项.也许我只需要正确阅读api ???
谢谢
小智 5
您应该阅读有关此主题的jquery文档:http://api.jquery.com/jQuery.ajax/ 您正在寻找的内容可能如下:dataType.
$.ajax({
url: 'request.html',
succes: function(data){
.. do something here! ..
},
dataType: 'html'
});
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助