在Jquery方法中获取WCF服务方法的问题 [英] Problem to Get WCF service method inside Jquery method

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

问题描述

您好我想在jquery GET方法中访问我的WCF服务方法

在一个解决方案中WCF服务的位置和/或
我的应用程序在另一个解决方案中


我的方法如下:

 $(#btnStartChat)。click(function(){
debugger;
// var U =/ Commons/Chat/ChatroomHome.aspx/CheckUser;
var U =http:// localhost:8004 / HRMSRestService.svc / CheckUser;
var name = $(#txtNickName)。val();
$ .ajax({
url:U,
data:{Name:name},
type:GET ,
contentType:application / json; charset = utf-8,
dataType:json,
成功:函数(数据){
alert('ok') ;
if($(#txtNickName)。val()。length> 0){
myHub.server.connect($(#tx tNickName)VAL())。
}
else {
alert(请输入姓名);
}
},
错误:function(ex){}
});


});



我无法访问服务方法,这意味着它不会解雇任何问题

告诉我为什么?

还有一件事,我在代码后面尝试了它也取消了注释但是可以取得任何成功。

解决方案

(#btnStartChat)。点击(function(){
debugger;
// var U =/ Commons/Chat/ChatroomHome.aspx/CheckUser;
var U =http:// localhost:8004 / HRMSRestService .svc / CheckUser;
var name =


(#txtNickName)。val();


.ajax({
url:U,
data:{Name:name},
type:GET,
contentType:application / json; charset = utf-8,
dataType:json,
成功:函数(数据){
alert('ok');
if(

Hello I want to access my WCF service method inside jquery GET method
Where WCF service in one solution and
My Application in another solution

My method is following below

$("#btnStartChat").click(function () {
               debugger;
               //var U = "/Commons/Chat/ChatroomHome.aspx/CheckUser";
               var U = "http://localhost:8004/HRMSRestService.svc/CheckUser";
               var name = $("#txtNickName").val();
               $.ajax({
                   url: U,
                   data:  {Name:name},
                   type: "GET",
                   contentType: "application/json; charset=utf-8",
                   dataType: "json",
                   success: function (data) {
                       alert('ok');
                       if ($("#txtNickName").val().length > 0) {
                           myHub.server.connect($("#txtNickName").val());
                       }
                       else {
                           alert("Please enter name");
                       }
                   },
                   error: function (ex) { }
               });


           });


I could not access the service method it means it's not firing is any issue
Tell me why?
And one more thing I have tried it in code behind also where is uncommented but could get any success.

解决方案

("#btnStartChat").click(function () { debugger; //var U = "/Commons/Chat/ChatroomHome.aspx/CheckUser"; var U = "http://localhost:8004/HRMSRestService.svc/CheckUser"; var name =


("#txtNickName").val();


.ajax({ url: U, data: {Name:name}, type: "GET", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { alert('ok'); if (


这篇关于在Jquery方法中获取WCF服务方法的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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