jQuery函数来调用WCF REST服务

问题描述:

什么是正确的函数调用下面的WCF REST服务jQuery函数来调用WCF REST服务

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

以下参数添加

term=apple 
username:joe password:pote 

并且是JSON它应该是有一个回调函数为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'); 
}; 

我不知道究竟如何你WCF服务当前配置,但下面的代码块将调用服务,其结果将被传递进入回调。

$.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 */ 
    } 
});