Jquery ajax通过ipaddress而不是localhost向wcfservice发出POST请求 [英] Jquery ajax GET POST request to wcfservice over ipaddress rather than localhost

查看:212
本文介绍了Jquery ajax通过ipaddress而不是localhost向wcfservice发出POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys,



过去三天我遇到了问题。

我创建了一个wcf服务,其中包括一些

Hello Guys,

I have stuck in a problem from the past three days.
I have created a wcf service which includes some

[OperationContract]

方法。

通过我的mvc应用程序使用jquery ajax我可以发送两种类型的请求(GET,POST)使用localhost或127.0.0.1启用wcfservice。但是当我使用自己的IP地址时,我无法发送请求,如http://192.168.18.5:15000/GetData。



请大家帮忙解决这个问题问题。



提前谢谢。

methods.
And through my mvc application using jquery ajax I am able to send both type of requests (GET, POST) to the wcfservice on by using localhost or 127.0.0.1. But I am not able to send a request when I use my own IPAddress like http://192.168.18.5:15000/GetData.

Please guys help to solve this problem.

Thanks in advance.

推荐答案

我们知道ajax调用不适用于跨域请求。在这里我猜这是你所面临的跨领域问题。



如果您的应用程序作为localhost运行,那么该服务也应该被称为localhost。 br />
对于IP地址也是如此,如果您将在localhost中运行该应用程序但是尝试通过提供IP地址获取服务它将无法工作。



请注意以下链接,如果这解决了您的问题,请告诉我们: -

http://stackoverflow.com/questions/13480652/jquery-ajax-call-to-c-sharp-web-service-error [< a href =http://stackoverflow.com/questions/13480652/jquery-ajax-call-to-c-sharp-web-service-error\"target =_ blanktitle =New Window> ^ ]



希望这会对你有所帮助。
As we know ajax calls will not work for cross domain request. Here what i guess this is the cross domain issue what you are facing.

Like if your application is run as localhost then the service also should be called as localhost.
Same for IP address also, if you will running the application in localhost but trying to fetch the service by giving IP address it will not work.

Please have alook into the below link and please let me know if this solves your issue :-
http://stackoverflow.com/questions/13480652/jquery-ajax-call-to-c-sharp-web-service-error[^]

Hope this will be helpful for you.


这篇关于Jquery ajax通过ipaddress而不是localhost向wcfservice发出POST请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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