Hi all,
I am not able to get xml response data from .aspx page of VS 2005. Following is the function which writes xml response on the client end:
protected void GetMailContents(double pdblMessageID) { string lstrMailContents = ""; DataSet lobjDs = new DataSet(); StringBuilder stringBuilder = new StringBuilder("");
lobjDs = mobjCProfileAndMail.GetMailContents(pdblMessageID);
if (lobjDs != null)
{
stringBuilder.Append("<Contents><From>");
stringBuilder.Append(lobjDs.Tables[0].Rows[0]["From"].ToString());
stringBuilder.Append("</From><To>");
stringBuilder.Append(lobjDs.Tables[0].Rows[0]["To"].ToString());
stringBuilder.Append("</To><Subject>");
stringBuilder.Append(lobjDs.Tables[0].Rows[0]["Subject"].ToString());
stringBuilder.Append("</Subject><Message>");
stringBuilder.Append(lobjDs.Tables[0].Rows[0]["Message"].ToString());
stringBuilder.Append("</Message></Contents>");
}
stringBuilder.Append("</MailContents>");
lstrMailContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?> \n ";
lstrMailContents += stringBuilder.ToString();
Response.ContentEncoding = Encoding.UTF8;
Response.Write(lstrMailContents);
Response.End();
}
Code on the client end:
$(document).ready(function()
{
var varURL = document.URL;
var varArr = varURL.split('=');
var varMessageID = varArr[1];
$.get("AjaxData.aspx?Mode=MODALDIALOG."+varMessageID, function(data)
{
$(data).find('Contents').each(function()
{
var varFrom = $(this).find('From').text();
var varTo = $(this).find('To').text();
var varSubject = $(this).find('Subject').text();
var varMessage = $(this).find('Message').text();
alert(varFrom);
});
});
});
I have written a alert for the data coming from the callback but getting nothing. If I am parsing any fixed xml then its working fine but in case getting response from the .aspx page got nothing. Is there any one who can help me out for this problem.
Thanks.