我使用AjaxRequest.Get()
方法從AjaxRequest。
以下是JavaScript的在analysis.aspx
AjaxRequest.get()不接受來自Response.Write()函數的文本/ Html函數
function getAnalysis(type) {
var innerHtml;
AjaxRequest.get(
{
'url': 'getAnalysis.aspx?type=' + type
, 'onSuccess': function (req) { innerHtml = req.responseText; }
}
);
document.getElementById("div_analysis").innerHTML = innerHtml;
}
時getAnalysis(type)
被稱爲analysis.aspx
一切直列進精 - AJAX請求正確提交和響應是發送正確。但最終值innerHTML
仍未定義。
以下是getAnalysis.aspx
代碼 -
protected void Page_Load(object sender, EventArgs e)
{
if(type == "somwthing") str = load();
Response.Clear();
Response.CacheControl = "no-cache";
Response.Write(str);
Response.End();
}
當我使用谷歌瀏覽器的JavaScript調試,我發現那innerHMTL
價值是不確定的,雖然一切正常。
所以我不明白爲什麼AjaxRequest類不接受Reponse.Write()
的文本輸出。
P.S. :我也試過Response.ContentType = "text/Html";
和Reponse.Fluch()
。
請提前指導我thnx。
是什麼'負載()'的定義時設置的功能的onSuccess在div內容,因爲它被稱爲異步? –
多數民衆贊成在虛擬,想法是,它返回一個字符串 – j4m4l