Hi I write a method on my page that return a XMLDocument.This is my method:
[System.Web.Services.WebMethod()]
public static System.Xml.XmlDocument MyGet()
{
string cnn=System.Configuration.ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString.ToString();
SqlConnection cn = new SqlConnection(cnn);
SqlCommand cmd = new SqlCommand("select * from region", cn);
SqlDataAdapter da = new SqlDataAdapter(cmd);
cn.Open();
DataSet dt = new DataSet();
da.Fill(dt);
XmlDocument xdoc=new XmlDocument();
xdoc.LoadXml(dt.GetXml());
return xdoc;
}
and this is my jQuery Ajax code:
$.ajax({
type: "POST",
url: "Default2.aspx/MyGet",
data: "{}",
dataType: "xml",
success: function(result) {
$(result).find("Table").each(function() {
alert($(this).find("RegionID").text());
});
}
but it does not work. If I write MyGet method in Web Service it works very fine. where is the problem? thanks alot