jquery ajax插件中的问题 [英] problem in jquery ajax plugin

查看:71
本文介绍了jquery ajax插件中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

i创建了一个jquery ajax插件,用于在没有回发的情况下使用DB,

并创建了一个名为services的Web表单,并将其用于url插件中的属性,

在我的插件中有数据属性,我传递给它两个文本框值,

服务页面代码(.cs),我想阅读文本框值,但我得到 null :(

我做错了什么?





hello,
i created a jquery ajax plugin for work with DB without postback,
and created a web form that name is services, and use this for "url" property in plugin,
in my plugin there are "data" property,i pass to it two textbox value,
in services page code (.cs),i want read textbox value, but i get null :(
What I'm doing wrong?


 $(document).ready(function () {
            refreshTime({ terget: $('#submitchangepassword') });
function refreshTime(options) {
            $.ajaxService({
                url: 'http://localhost:1549/Store/Pages/services.aspx?ServiceName=hello-world',
                data: { oldpassword: $('div#contentz4').find('#oldpassword').val(), newpassword: $('div#contentz4').find('#newpassword').val() },
                onStartService: function () { $(options.target).addClass('loading'); },
                onEndService: function () { $(options.target).removeClass('loading'); },
                onResponse: function (response) {
                    if (response.result == '1') {
                        $.pushMessage({ message: 'you'r password success changed', messageClass: 'success-message', delay: 3000 });
                    }
                    else {
                        $.pushMessage({ message: 'error in chage password', messageClass: 'success-message', delay: 3000 });
                    }
                }
            });
        }
        });



我的插件:



services.cs中的和c#代码


my plugin:

and c# code in services.cs

protected void Page_Load(object sender, EventArgs e)
{
    System.Threading.Thread.Sleep(2200);
    string serviceName = this.Request.QueryString["ServiceName"];
    if (!string.IsNullOrEmpty(serviceName))
    {
        switch (serviceName.ToLower().Trim())
        {
            case ("hello-world"):
                string oldpassword = Request["oldpassword"];
                string newpassword = Request["newpassword"];

                try
                {
                    System.Web.Security.MembershipUser usr = System.Web.Security.Membership.GetUser();
                    if (usr.ChangePassword(oldpassword, newpassword))
                        ResponseResultCollection["result"] = "1";
                    else
                        ResponseResultCollection["result"] = "0";
                }
                catch (Exception ex) { Response.Write("An exception occurred: " + Server.HtmlEncode(ex.Message) + ". Please re-enter your values and try again."); }
                break;
        }
    }
    Response.Write(this.GenerateResponseResult());
    Response.End();
}

private string GenerateResponseResult()
{
    string result = "";

    foreach (string key in this.ResponseResultCollection.AllKeys)
    {
        result += string.Format(",\"{0}\":\"{1}\"", key, this.ResponseResultCollection[key]);
    }

    if (!string.IsNullOrEmpty(result))
    {
        result = result.Substring(1);
        result = "{" + result + "}";
    }

    return result.ToString();
}

推荐答案

document ) .ready( function (){
refreshTime({terget:
(document).ready(function () { refreshTime({ terget:


' #submitchangepassword')});
function refreshTime(options ){
('#submitchangepassword') }); function refreshTime(options) {


.ajaxService({
url:' http: //localhost:1549/Store/Pages/services.aspx?ServiceName=hello-world'
数据:{oldpassword:
.ajaxService({ url: 'http://localhost:1549/Store/Pages/services.aspx?ServiceName=hello-world', data: { oldpassword:


这篇关于jquery ajax插件中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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