Click here to Skip to main content
15,893,486 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi -

I was given a link to a public web service that was created. I'm trying to call this service passing a parameter but I'm not that good with services and still learning them.

The webmethod requires a part number and I'm not sure really how to pass that in order to return data.

Here is my ajax call
var partNumber = 27882;
$.ajax({
    type: "POST",
    url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts" + "?" + partNumber,
    contentType: "application/json; charset=utf-8",
    dataType: "jsonp",
    success: function (data) {
        alert(data.d)
    },
    error: function () {
        console.log("obviously didnt work");
    }
});


Thanks additionally any articles to help with learning these would be greatly appreciated. Lot of the things I'm running across are very specific and i'm just trying to get a good overall understanding.
Posted

1 solution

It depends on the service expects, you'll need to ask whoever provides it. If it wants it on the URL then it will be something like

type: "GET",
url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts?partNumber = " + partNumber,

but you'll have to ask them what the name of the parameter they are expecting is. If it is to be posted then it'll be like

type: "POST",
url: "http://xxxxxx.xxxxx.com/xxxx/Service.asmx/GetParts",
data: "{partNumber:" + partNumber + "}",

ultimately you'll have to consult the documentation for the service and google how you call web services from jQuery for relevant examples.
 
Share this answer
 
Comments
Troy Bryant 4-Jun-15 15:20pm    
figured out the request but getting syntax error int he response here is the beginning "Uncaught SyntaxError: unexpected token <"

error occurs ---> <!--?xml version="1.0" encoding="utf-8"?-->
<PartList PartCount="34">
<Part>
<id>670946
<partNo>5030060</partNo>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900