How to call an M3 Web Service using jQuery

Here’s a simple example of calling an M3 web service using jQuery. In this example, my web service has two input fields and 3 output fields. You’ll obvously need to change the URL to the web service and the format of your soap request to match your WSDL.

    <title>example m3 soap web service with jquery</title>
        $(document).ready(function () {
   = true;

            $("#submitBtn").click(function (event) {
                var wsUrl = "";

                var soapRequest = '';
                soapRequest += '' + $("#cusno").val() + '' + $("#addressId").val();
                soapRequest += '';
                    type : "POST",
                    url : wsUrl,
                    contentType : "text/xml",
                    dataType : "xml",
                    data : soapRequest,
                    success : processSuccess,
                    error : processError

        function processSuccess(data, status, req) {
            if (status == "success") {
                var ois002 = $(req.responseText).find('OIS002');
                var response = ois002.find('Name').text() +
" + ois002.find('AddressLine1').text() + "
" + ois002.find('AddressLine2').text(); $("#response").html(response); } } function processError(data, status, req) { alert(req.responseText + " " + status); } </head> <body> <h3>Calling Web Services with jQuery/AJAX</h3> <h4>Input</h4> Customer Number / Address ID <input id="cusno" type="text" /> <input id="addressId" type="text" /> <input id="submitBtn" value="Submit" type="button" /> <h4>Output</h4> <div id="response"/> </body> </html>

Here’s the example HTML page, with my input fields and the response I get when I submit the form:

jquery example


Related articles

Published by

Jessica King

eCommerce and ERP Integration Technology Consultant

11 thoughts on “How to call an M3 Web Service using jQuery”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s