zoukankan      html  css  js  c++  java
  • ajax调用后台webservice返回JSON字符

    后台代码:

    [WebMethod]
    public static string LoginTest(string userCode, string password)
    {
    UserManageCenterService service = new UserManageCenterService();
    string msg = string.Empty;
    service.AuthenticateUser(userCode, password, 10000, out msg);

    if (msg == "验证成功")
    {
    string callBackURL = System.Configuration.ConfigurationManager.AppSettings["CallBackURL"].ToString();
    msg = "{"sign":"authenticated","url":" + '"' + callBackURL + '"' + "}";
    return msg;
    }
    return msg;
    }

    前台代码:

    $(document).ready(function () {
    $("#btnlogin").click(function () {
    if (CustomLogin() != false) {
    $.ajax(
    {
    type: "POST",
    contentType: "application/json",
    url: "Login.aspx/LoginTest",
    data: "{'userCode': '" + $("#txtUserName").val() + "', 'password':'" + $("#txtPassword").val() + "'}",
    dataType: "json",
    success: function (msg) {
    ajaxobj = eval("(" + msg.d + ")");
    if (ajaxobj.sign == "authenticated") {
    window.location.href = ajaxobj.url;
    }
    else {
    alert(msg.d);
    }
    }
    });
    }
    });
    });

  • 相关阅读:
    mybatis-spring 集成
    maven 插件深入了解
    maven 常用插件3
    maven 插件2
    <转载> maven 详解 http://www.cnblogs.com/binyue/p/4729134.html
    linux base shell 基础语法
    浏览器运行原理
    <转载> js 闭包
    dubbo 学习资料
    HTTP
  • 原文地址:https://www.cnblogs.com/star2012/p/4635274.html
Copyright © 2011-2022 走看看