我从$ .ajax从服务器获取内容。而这些内容的HTML字符串,他们有自己的风格欧文,以下是我的代码:
var dataStr = "indexOfStart=" + 0;
$(document).ready(function() {
$("#idgetData").click(function() {
$.ajax({
type: "post",
url: "http://localhost:1897/Content/Services/Service1.asmx/GetArticlesDuring",
dataType: "jsonp",
data: { indexOfStart: 0, indexOfEnd: 20 },
jsonp: 'back',
success: function (result) {
var res = decodeURIComponent(result.Result);
document.getElementById("content").innerHTML = res;
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
targetDiv = $("#data");
if (errorThrown || textStatus == "error" || textStatus == "parsererror" || textStatus == "notmodified") {
targetDiv.replaceWith("请求数据时发生错误!");
return;
}
if (textStatus == "timeout") {
targetDiv.replaceWith("请求数据超时!");
return;
}
},
complete: function() {
//addStyle("Default.css");
//addStyle("all.css");
document.write('');
}
});
});
});
function addStyle(stylePath) {
var container = document.getElementsByTagName("head")[0];
var addStyle = document.createElement("link");
addStyle.rel = "stylesheet";
addStyle.type = "text/css";
addStyle.href = stylePath;
container.appendChild(addStyle);
}
问题是内容的风格不能被加载和工作, 谁能帮助我吗?
2013-07-10
francis