asp.net ajax - xmlhttp request -
i have created button on web browser when clicked should execute asp file.how create this!! dont know why xmlhttp request not being sent.i tried on localhost,but still nothing seems work!! code goes button onclick i.e javascript goes this!!
custombutton = { 1: function () { var xmlhttp; if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari xmlhttp=new xmlhttprequest(); } else {// code ie6, ie5 xmlhttp=new activexobject("microsoft.xmlhttp"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readystate==4 && xmlhttp.status==200) { document.getelementbyid("mydiv").innerhtml=xmlhttp.responsetext; } } xmlhttp.open("get","http://localhost/default.asp",true); xmlhttp.send(); } }
i using htdocs folder wherein default.asp file located.the code of default.asp is
<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="webapplication9._default" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>untitled page</title> </head> <body> <form id="form1" runat="server"> <% ="hello world!" %> </form> </body> </html>
why code doesnt work????
try debug code of firebug script debugger on firefox.
also can analyze request , response using http fox addon in firefox.
by using can see whether request going correct file or not. response coming.
Comments
Post a Comment