|
-
Feb 4th, 2012, 08:15 AM
#1
Thread Starter
Lively Member
call web service
Dear forum.
i try to access to a resource in the server,via Javascipt whit XMLHttpRequest() object.
Just for begin, i access to a text file named -TextFile1.txt-, and is working very easy and at first time. This is the code:
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest() ;
xmlhttp.onreadystatechange=EV_RISP; //Event handler
xmlhttp.open("get", "TextFile1.txt", true); //Source to access
xmlhttp.send() ;
}
and the event:
function EV_RISP() {
if (xmlhttp.readyState == 4) {
alert(xmlhttp.responseText);
}
else {
alert("NOK");
}
}
Now i try to access to a web service in ASP.NET ,the simple HelloWorld
but is not working
The web service is alwai the same:
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello-World";
}
}
and my code in javascript is modified just in the line of destination source
xmlhttp.open("get", "webservice1/HelloWorld", true);
and i get the NOK of the alert code.
Many thanks
Roberto
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|