i am using AjaxRequest.Get()
method from AjaxRequest.
following is the inline javascript in analysis.aspx
function getAnalysis(type) {
var innerHtml;
AjaxRequest.get(
{
'url': 'getAnalysis.aspx?type=' + type
, 'onSuccess': function (req) { innerHtml = req.responseText; }
}
);
document.getElementById("div_analysis").innerHTML = innerHtml;
}
when getAnalysis(type)
is called in analysis.aspx
everything goes fine - ajax request is properly submitted and response is send properly. But at the end value of innerHTML
remains undefined.
Following is the code of 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();
}
When i debugged javascript using google chrome, i found that value of innerHMTL
is undefined, although everything went fine.
So i dont understand why AjaxRequest class is not accepting text output from Reponse.Write()
.
P.S. : I have also tried Response.ContentType = "text/Html";
and Reponse.Fluch()
.
please guide me thnx in advance.
You need to set the div contents in the onsuccess function since it is called asynchronously when the AJAX request completes