Z
Zeba
Hi guys!
I'm new to JS / Ajax; I've been trying to do an Ajax call to my
Webservice ( I'm using C# for code-behind). I'm not using any of the
libraries available. I am sending my CustID to the webservice and the
webservice returns a Dataset that contains various customer details
taken from database. I have tested that the Webservice itself works.
But my ajax call is not working.
My ajax call is something like :
this.URL = "http://localhost/RegistrationAjax/Retrieve.asmx";
this.webMethod = "getCustomerDetails";
var url = this.URL +"/"+ this.webMethod;
this.request.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
this.request.open('POST', url, true);
this.request.onreadystatechange = this.onComplete;
this.request.send("custID="+cust_id);
I also tried it using GET, as :
var url = this.URL +"?op="+ this.webMethod;
this.request.open('GET', url, true); //Also tried
this.request.open('GET', url, false);
this.request.onreadystatechange = this.onComplete;
this.request.send("custID="+cust_id);
(also tried appending the cust_id to the url for GET )
But what I get back ( i.e. what I see in the Response tab for the GET
entry in the console of Firebug) is the entire html of the webservice
itself. Why am i not getting the Data ??!
In the case of POST, I get an exception that says:
uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.setRequestHeader]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
http://localhost/RegistrationAjax/JS/RemoteControl.js :: anonymous ::
line 56" data: no]
Please help me out !!!! How do I actually get to my Webservice from my
Javascript ??!
Thanks !
I'm new to JS / Ajax; I've been trying to do an Ajax call to my
Webservice ( I'm using C# for code-behind). I'm not using any of the
libraries available. I am sending my CustID to the webservice and the
webservice returns a Dataset that contains various customer details
taken from database. I have tested that the Webservice itself works.
But my ajax call is not working.
My ajax call is something like :
this.URL = "http://localhost/RegistrationAjax/Retrieve.asmx";
this.webMethod = "getCustomerDetails";
var url = this.URL +"/"+ this.webMethod;
this.request.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
this.request.open('POST', url, true);
this.request.onreadystatechange = this.onComplete;
this.request.send("custID="+cust_id);
I also tried it using GET, as :
var url = this.URL +"?op="+ this.webMethod;
this.request.open('GET', url, true); //Also tried
this.request.open('GET', url, false);
this.request.onreadystatechange = this.onComplete;
this.request.send("custID="+cust_id);
(also tried appending the cust_id to the url for GET )
But what I get back ( i.e. what I see in the Response tab for the GET
entry in the console of Firebug) is the entire html of the webservice
itself. Why am i not getting the Data ??!
In the case of POST, I get an exception that says:
uncaught exception: [Exception... "Component returned failure code:
0x80004005 (NS_ERROR_FAILURE) [nsIXMLHttpRequest.setRequestHeader]"
nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
http://localhost/RegistrationAjax/JS/RemoteControl.js :: anonymous ::
line 56" data: no]
Please help me out !!!! How do I actually get to my Webservice from my
Javascript ??!
Thanks !