Possible Duplicate:
Consuming a Web service using Javascript
Please note that I’m still getting used to JavaScript. Basically I need to write an HTML file that uses Javascript to call a couple of web service methods (from the same server as the HTML file) without using Ajax or probably much of anything else that we’d have to install on there separately. We already have the web service up and running fine, as well as some JS. This needs to work for IE, FF, and Chrome, including for computers that are a couple of years “behind the times”. What is a really simple way to do this? Again, I’m still kind of getting my feet wet with JavaScript, so I’m having a hard time following and using some of the examples I’ve seen. Thanks!
EDIT: Here’s an example of the kind of thing I’ve been trying:
<html>
<head>
<title>Hello World</title>
<script language="JavaScript">
var iCallID;
function InitializeService(){
alert("spam");
try {
service.useService(<WSDL address>,
"HelloWorldService");
} catch (e) {
alert(e.message);
}
alert("spam");
service.HelloWorldService.callService("HelloWorld");
alert("spam");
}
function ShowResult(){
alert("spam");
alert(event.result.value);
alert("spam");
}
</script>
I get “spam”, then “Object doesn’t support this property or method”, then nothing.
Ok, AJAX has been around since donkey’s years, really. But since you’re not familiar with JS, here’s a little copy-paste function you could use:
Usage:
This will send an ajax request back to the server, with a POST parameter
id, value12… play around with that. A few things that can be useful: JSON, and -though I’m not a big fan- jQuery, it has a ready built-in$.ajaxmethod, just pass an object literal and you’re good to go.Feel free to edit this function as you please