pretty sure it's simple answer but so many ajax articles and none of my searches have returned a solution.
Trying to reference my .net web service that recieves a string and returns a string.
i seem to be getting an error on this line whatsthematter.asmx/SayHello");
function call_server()
{
request.open("GET", "whatsthematter.asmx/SayHello");
request.onreadystatechange = sever_interaction;
request.send('somenumber');
}
full code
webservice function
html page
Trying to reference my .net web service that recieves a string and returns a string.
i seem to be getting an error on this line whatsthematter.asmx/SayHello");
function call_server()
{
request.open("GET", "whatsthematter.asmx/SayHello");
request.onreadystatechange = sever_interaction;
request.send('somenumber');
}
full code
webservice function
Code:
public string SayHello(string yourname) {
string returnme ="";
returnme="Hello there "+yourname+".";
return returnme;
}
Code:
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] >
<head>
<script>
function creat_Object()
{
var xmlhttp;
// This if condition for Firefox and Opera Browsers
if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
try
{
xmlhttp = new XMLHttpRequest();
}
catch (e)
{
alert("Your browser is not supporting XMLHTTPRequest");
xmlhttp = false;
}
}
// else condition for ie
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
return xmlhttp;
}
var request = creat_Object();
function sever_interaction()
{
if(request.readyState == 1)
{
document.getElementById('aja_cnts').innerHTML='';
document.getElementById('aja_cnts').innerHTML = "<span style='background-color:orange;'>Loading...</span>";
}
if(request.readyState == 4)
{
var answer = request.responseText;
document.getElementById('aja_cnts').innerHTML='';
document.getElementById('aja_cnts').innerHTML = answer;
}
}
function call_server()
{
request.open("GET", "whatsthematter.asmx/SayHello");
request.onreadystatechange = sever_interaction;
request.send('somenumber');
}
</script>
</head>
<body>
<table width="80%" border="1" cellspacing="2">
<caption>
Using AJAX
</caption>
<tr>
<td width="16%" height="90"> </td>
<td width="23%"><label>
<input type="button" name="Button" value="Button" onclick="call_server();" />
</label></td>
<td width="61%"><div id="aja_cnts"> </div></td>
</tr>
</table>
</body>
</html>