javascript调用wcf服务 [英] javascript call to a wcf service

查看:58
本文介绍了javascript调用wcf服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii,



我做了一个WCF REST服务,它以JSON格式返回响应,现在我想从javascript调用它。但是当我尝试打电话给我,我看不到任何回复。

要拨打javascript电话,我写了这个:

 <   script     src   =  Scripts / jquery-1.5.2.min.js   类型  =  text / javascript >  
< / script >
< script language = javascript type = < span class =code-keyword> text / javascript >
function Greeting(){

$(#btnWCFREST)。click(function(){
$ .ajax({
url:http:// localhost:8732 / Services / RoleService / json / Role / provider,

类型:GET,
dataType:json,

contentType:application / json; charset = utf-8,
成功:函数(msg){
alert(msg);
},
错误:函数(msg){
alert( 失败);
}
}

);
}
}


< / script >





如何得到回复。我哪里出错?



谢谢..

解决方案

(#btnWCFREST)。click(function(){


.ajax({
url :http:// localhost:8732 / Services / RoleService / json / Role / provider,

类型:GET,
dataType:json,

contentType:application / json; charset = utf-8,
成功:函数(msg){
alert(msg);
},
错误:function(msg){
alert(Failed);
}
}

);
}
}


< / script >





如何获得回复。我哪里错了?



谢谢..


< script type =text / javascript>



var类型;

var Url =http:// .....//服务网址;

var Data;

var ContentType;

var DataType;

var ProcessData;

var method;

//调用WCF服务的通用函数





函数CallService(){

Hii,

I have made a WCF REST service which returns the response in JSON format and now I want to call it from javascript.But when I try to call it I couldn''t view any response.
To make a javascript call I have written this:

<script src="Scripts/jquery-1.5.2.min.js" type="text/javascript">
   </script>
   <script language="javascript" type="text/javascript">
       function Greeting() {
          
           $("#btnWCFREST").click(function() {
           $.ajax({
           url:"http://localhost:8732/Services/RoleService/json/Role/provider",
          
           type:"GET",
           dataType:"json",
         
            contentType:"application/json; charset=utf-8",
            successs:function(msg){
            alert(msg);
            },
            Error:function(msg){
            alert("Failed");
            }
            }

            );
            }
            }


   </script>



How can I get the response.Where Am I going wrong?

Thanks..

解决方案

("#btnWCFREST").click(function() {


.ajax({ url:"http://localhost:8732/Services/RoleService/json/Role/provider", type:"GET", dataType:"json", contentType:"application/json; charset=utf-8", successs:function(msg){ alert(msg); }, Error:function(msg){ alert("Failed"); } } ); } } </script>



How can I get the response.Where Am I going wrong?

Thanks..


<script type="text/javascript">

var Type;
var Url ="http://..... "// service URL;
var Data;
var ContentType;
var DataType;
var ProcessData;
var method;
//Generic function to call WCF Service


function CallService() {


这篇关于javascript调用wcf服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆