Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am a beginner in ajax asp.net.
When i want to back data from server page to client page after ajax request, i do not know how to send back data to client.
C#
string te = "hello world";
System.Text.StringBuilder sb = new System.Text.StringBuilder("<?xml version=\"1.0\"?>");
        sb.Append("<Employee>");
        sb.Append("<EmployeeID><![CDATA[" + te + "]]></EmployeeID>");
        sb.Append("<FirstName><![CDATA[" + te + "]]></FirstName>");
        sb.Append("<LastName><![CDATA[" + te + "]]></LastName>");
        sb.Append("<Phone><![CDATA[" + te + "]]></Phone>");
        sb.Append("<Title><![CDATA[" + te + "]]></Title>");
        sb.Append("<BirthDate><![CDATA[" + te + "]]></BirthDate>");
        sb.Append("<HireDate><![CDATA[" + te + "]]></HireDate>");
        sb.Append("</Employee>");        
        Response.ContentType = "text/xml";
        Response.CacheControl = "no-cache";
        Response.Write(sb.ToString());

And in client page i receive it in this way:
JavaScript
if(XMLHTTP.status == 200) {        
	var x=XMLHTTP.responseXML.documentElement;
		}

but there is no info in var x.
why?
Thanks in advanced.
Posted
Updated 4-Aug-13 4:29am
v4
Comments
Status BreakPoint 4-Aug-13 10:25am    
It seems the CDATA section was not close.
Please check result XML.

1 solution

You need to provide more information.

Btw, creating an xml document using a string builder is not a good practice. I would rather user XmlDocument [^]class to create xml document.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900