jQuery ajax调用仅在本地主机上有效 [英] jquery ajax call works only on localhost

查看:281
本文介绍了jQuery ajax调用仅在本地主机上有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用jquery ajax从asp.net后端方法获取数据,如下所示:

i m using jquery ajax to get data from an asp.net back end method like this:

$.ajax({
        cache: false,
        type: "POST",
        url: '<%= Page.ResolveUrl("~/Live/Live.aspx/GetViews") %>',
        content: "json",
        contentType: "application/json; charset=utf-8",
        data: "{ 'Altid' : '" + GetAltId() + "' }",
        success: function (msg) {
            $("#backEndCount").text(msg.d);
        },
        fail: function (msg) {
            $("#backEndCount").text(msg.d);
        }
    });



和后端方法:



and the back end method:

[WebMethod]
public static string GetViews(int Altid)
{
    return Live.count(Altid);
}



此调用在本地可以正常运行,但是在远程服务上,我将页面html作为响应而不是常规响应"d".

是什么问题,谢谢.



this call works fine locally, but on the remote service i get the page html as a response instead of the normal response which is the "d".

what is the problem, thanks.

推荐答案

.ajax({ 缓存: false , 类型:" , 网址:' <%= Page.ResolveUrl(〜/Live/Live.aspx/GetViews")%> ', 内容:" , contentType:" , 数据:" + GetAltId()+ '}", 成功:功能(msg){
.ajax({ cache: false, type: "POST", url: '<%= Page.ResolveUrl("~/Live/Live.aspx/GetViews") %>', content: "json", contentType: "application/json; charset=utf-8", data: "{ 'Altid' : '" + GetAltId() + "' }", success: function (msg) {


(" #backEndCount").text(msg.d); }, 失败:功能(msg){
("#backEndCount").text(msg.d); }, fail: function (msg) {


(" #backEndCount").text(msg.d); } });
("#backEndCount").text(msg.d); } });



和后端方法:



and the back end method:

[WebMethod]
public static string GetViews(int Altid)
{
    return Live.count(Altid);
}



此调用在本地可以正常运行,但是在远程服务上,我将页面html作为响应而不是常规响应"d".

有什么问题,谢谢.



this call works fine locally, but on the remote service i get the page html as a response instead of the normal response which is the "d".

what is the problem, thanks.


这篇关于jQuery ajax调用仅在本地主机上有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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