Go Back

AJAX xmlHttpRequest and ASP.net Forms

Last week I built a calendar application that displays a large calendar in the content area of the website with the list of events in the right hand sidebar. When a visitor clicks on a day in the calendar the right hand sidebar updates with the list of events for that day. This is done using Ajax similar to the example at W3Cschool

The call for the data uses xmlHttp.open(“Get”, “getevents.aspx?x=12”, true).

This works great in firefox, and safari, however IE7 said no. After some thinking I realized the form tags and etc from the aspx page return was causing the problem.

After some research I discover this in a forum at ASP.net

In case you want to display only the content within the form tags, you can do

var s = xmlhttp.responseText;
s = s.slice(s.indexOf("<fo" + "rm"));
s = s.replace("</body>","");
s = s.replace("</html>","");
s = s.replace(/<form/ig,"<formdisabled");
document.getElementById('T1').innerHTML = s;

Problem solved, thanks Prashant and asp.net

  • Facebook
  • Twitter
  • DZone It!
  • Digg It!
  • StumbleUpon
  • Technorati
  • Del.icio.us
  • NewsVine
  • Reddit
  • Blinklist
  • Add diigo bookmark
Post a comment!
  1. Formatting options