为什么不将该函数返回responseText?
function LoadBookmarksAsXml()
{
return $.ajax(
{
type: 'GET',
async: false,
url: 'http://www.google.com/bookmarks/?output=xml&num=10000'
}).responseText;
}
(如果我定义一个成功回调函数并将 async 设置为 true,它就可以工作!)提前致谢!!
编辑:不用担心跨域调用;user603003 说(在对现已删除的答案的评论中)这是在允许跨域请求的 Chrome 扩展程序中。
如果有人想做同样的解决方案:
return $.ajax(
{
type: 'GET',
async: false,
url: 'http://www.google.com/bookmarks/?output=xml&num=10000',
});
(您将获得一个 XMLHTTPRequest 对象。)