This webservice is running fine and seems to work ok.
I also have a simple javascript page below.
I cannot seem to get the Javascript page to post requests to the webservice.
I have been fiddling with it for hours and just cannot seem to get it to work.
I have adjust the firewall to accept all incoming and outgoing connection not that i think this would matter.
Please could someone help. I would prefer not to go down the route of having and aspx page on the front end of my website as eventually i would like to replace my webservice with a php one but do not have php skills atm.
The log i have set up in my vb webservice looks fine when using the firefox to invoke the service but my javascript does not seem to do anything.
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld(ByVal hell As String) As String
Dim FILE_NAME As String = "C:\Webhosting1\asmxlog.txt"
Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
objWriter.WriteLine(hell)
objWriter.Close()
Return "Hello World smile" & hell
End Function
End Class
and javascript is here
<html>
<script type="text/javascript" language="javascript">
var myReq = new XMLHttpRequest();
function callWSMethod1()
{
if (window.XMLHttpRequest)
{
var url = "http://localhost:61422/Webhosting1/Service.asmx?op=HelloWorld";
I might be wrong, but I used to be convinced that one can not perform an AJAX request to the localhost.
I suppose that all tends to depend upon the circumstances. I develop om my own computer which runs Linux. When I am working on an AJAX project I start up Apache on my computer and have no problems sending or receiving AJAX, although I always use the format as in 'http://127.0.0.1/ajax.php'
Thanks for the idea there.
I had already tried replacing the localhost with the ip and it did not change anything.
I have now tried running this from another box on my network and still no luck.
I am new to the business of web services and guess that i have just over looked something simple like a setting somewhere on my box.
Cheers in advance for any more assistance
I might be wrong, but I used to be convinced that one can not perform an AJAX request to the localhost.
I suppose that all tends to depend upon the circumstances. I develop om my own computer which runs Linux. When I am working on an AJAX project I start up Apache on my computer and have no problems sending or receiving AJAX, although I always use the format as in 'http://127.0.0.1/ajax.php'
Sure, but if you open the web document with the proper address (like http://localhost/etc...) not straight.
Ashw1984, Regarding the ASP.NET, well, I guess that you should use the IIS server emulator. And if you are working on Win7 as OS, well, things go a little bit tricky there... It might be a problem of the IIS configuration, rather...
Just wondered if anyone knows why my responseText from my xmlhttprequest would be blank.
I am using the webservice exactly as it is earlier in this post. Running it through iis.
The following script does get to the webservice ( i know this as i have logs in asmxlog.txt file (see webservice code)) but i cannot seem to get and data back. I have tried on the local box and a remote one and it has the same symptom. As you can see by my comments is have tried fiddling with it a lot.
cheers in advance for assistance guys.
<html>
<script type="text/javascript" language="javascript">
var myReq = new XMLHttpRequest();
//var myReq = new ActiveXObject("MSXML2.XMLHTTP")
function callWSMethod1()
{
if (window.XMLHttpRequest)
{
var url = "http://192.168.1.1:9090/Service.asmx/HelloWorld?hell=smile";
//var url = "http://192.168.1.1:9090/Service.asmx?op=HelloWorld";
Just to check, you might check the status of the request in your 'CheckStatus1()' function. The fact that the readyState equals 4 does not necessarily signify that it was successful, only that it is done. Substitute:
Code:
alert(myReq.status);
for
Code:
alert(myReq.responseText);
just to check. If status is anything other than 200 this will give you some idea of the nature of the error.
For what its worth, my understanding is that you get status code zero when the AJAX request is trying to access a local file rather than going though a server. It would seem that FF does not recognize this in your situation, but that IE does.
Bookmarks