简体   繁体   中英

jquery function to call WCF REST service

What would be the correct function to call the following WCF REST service

http://xx.x.x.xxx/GAdmin/WGService/Service1.svc/RetrieveData?term=apple

with the following parameters added

term=apple
username:joe password:pote

and being json it should be have a callback function for jsonp

  $.getJSON('http://xx.x.x.xxx/GAdmin/WGService/Service1.svc/RetrieveData?term=apple
  callback=?'{
 content: { username: "joe", password: "pote" },
 function (data)
 {
    alert('Received ' + data + ' results');
 };

I don't know exactly how you're WCF service is currently configured, but the following code block will call the service and the results would be passed into the callback.

$.ajax({
    cache: false,
    type: "GET",
    async: false,
    url: "http://xx.x.x.xxx/GAdmin/WGService/Service1.svc/RetrieveData?term=apple",
    contentType: "application/json",
    success: function (response) {
        /* SUCCESS FUNCTION */
    },
    error: function (error) {
        /* ERROR FUNCTION */
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM