J
JDeats
Note, I am not trying to use the Microsoft AJAX Framework, yes I am
aware of what it is and what it does.... The techniques refered to as
"AJAX" predate this toolkit and ASP.NET 2.0
What I am trying to accomplish is the most minimal cross-platform web
browser "AJAX" implementation using .NET 2.0, here is what I have so
far in the client and the server.
When the user clicks in Internet Explorer this does exactly what I
would expect, I get a JavaScript alert box with the data I pass in to
SendIt.aspx saying JAMES1.
So the problem is this doesn't work from other web browsers, I tried
with Safari for Windows as well as FireFox 2.0 and the alert box never
appears, it seems the XMLHttpRequest object does not work in non-IE
browsers.
CLIENT (this page has an .HTML extenshion on the web server)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script language=javascript>
function submitForm()
{
var xhr;
try { xhr = new XMLHttpRequest(); }
catch(e)
{
xhr = new ActiveXObject(Microsoft.XMLHTTP);
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)
{
var x1 = xhr.responseText;
alert(x1);
}
else
{
alert("failed");
}
}
};
xhr.open("POST", "http://localhost:2160/WebSite1/SendIt.aspx",
true);
xhr.send("JAMES1");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<button id="Button1" value="start2"
onclick="submitForm();">Test2</button>
</div>
</form>
</body>
</html>
SERVER (here is the Page_Load event from the ASPX page)
protected void Page_Load(object sender, EventArgs e)
{
string txt = "";
string input = null;
StreamReader sr = new StreamReader(Request.InputStream);
while ((input = sr.ReadLine()) != null)
{
txt += input;
input = null;
}
sr.Close();
sr.Dispose();
//Request.SaveAs(@"c:\temp2\request.txt", true);
Response.Write(txt);
Response.End();
}
aware of what it is and what it does.... The techniques refered to as
"AJAX" predate this toolkit and ASP.NET 2.0
What I am trying to accomplish is the most minimal cross-platform web
browser "AJAX" implementation using .NET 2.0, here is what I have so
far in the client and the server.
When the user clicks in Internet Explorer this does exactly what I
would expect, I get a JavaScript alert box with the data I pass in to
SendIt.aspx saying JAMES1.
So the problem is this doesn't work from other web browsers, I tried
with Safari for Windows as well as FireFox 2.0 and the alert box never
appears, it seems the XMLHttpRequest object does not work in non-IE
browsers.
CLIENT (this page has an .HTML extenshion on the web server)
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<script language=javascript>
function submitForm()
{
var xhr;
try { xhr = new XMLHttpRequest(); }
catch(e)
{
xhr = new ActiveXObject(Microsoft.XMLHTTP);
}
xhr.onreadystatechange = function()
{
if(xhr.readyState == 4)
{
if(xhr.status == 200)
{
var x1 = xhr.responseText;
alert(x1);
}
else
{
alert("failed");
}
}
};
xhr.open("POST", "http://localhost:2160/WebSite1/SendIt.aspx",
true);
xhr.send("JAMES1");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<button id="Button1" value="start2"
onclick="submitForm();">Test2</button>
</div>
</form>
</body>
</html>
SERVER (here is the Page_Load event from the ASPX page)
protected void Page_Load(object sender, EventArgs e)
{
string txt = "";
string input = null;
StreamReader sr = new StreamReader(Request.InputStream);
while ((input = sr.ReadLine()) != null)
{
txt += input;
input = null;
}
sr.Close();
sr.Dispose();
//Request.SaveAs(@"c:\temp2\request.txt", true);
Response.Write(txt);
Response.End();
}