ajax 获取php object object object object,ajax 返回数据[Object Object]解决办法

ajax 返回数据[Object Object]

问 这里面到底出现什么问题,

前台

html>

function Send() {

var loginUserId = $("#").val();

$.ajax({

//提交方式

type: "Post",

//路径

url: "Code/ValidCode.ashx?Method=Send",

data: {

Loginid: loginUserId,

d: new Date()

},

dataType: "text",

//返回数据-需要返回JSON格式的数据(Jquery 1.4版本+以后要求返回数据格式是严格的JSON格式的数据)

success: function (json) {

alert(json);

//if (json.MessageText == 1) {

//    alert("发送邮件成功.");

//} else if (json.MessageText == 0) {

//    alert("Send mail success.");

//}

},

error: function (e) {

alert(e);

}

});

}

验证

发送验证码

ASHX文件:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Reflection;

using System.Text;

using System.Web;

using System.Web.Script.Serialization;

using System.Web.SessionState;

using Entity;

using Newtonsoft.Json;

namespace WebCrm.Code

{

/// 

/// ValidCode 的摘要说明

/// 

public class ValidCode : IHttpHandler

{

HttpContext _httpContext;

HttpCookie _cookie;

public void ProcessRequest(HttpContext context)

{

//不让浏览器缓存

context.Response.ContentType = "text/plain";

//context.Response.Buffer = true;

//context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1);

//context.Response.AddHeader("pragma", "no-cache");

//context.Response.AddHeader("cache-control", "");

//context.Response.CacheControl = "no-cache";

_httpContext = context;

string method = _httpContext.Request["Method"].ToString();

MethodInfo methodInfo = this.GetType().GetMethod(method);

methodInfo.Invoke(this, null);

}

/// 

/// 发送验证码

/// 

public void Send()

{

//Json数据返回格式

Entity.ReturnsData returnsData = new Entity.ReturnsData();

//获取对象值

string login = _httpContext.Request["Loginid"];

//获取当前用户缓存

Entity.LoginInfo loginInfo = BLL.CacheBll.GetCache(login) as Entity.LoginInfo;

if (loginInfo != null)

{

int d = 0;

//判断当前是否存在Cookies

if (_httpContext.Request.Cookies["ValidInfo"] == null)

{

Random rand = new Random();

d = rand.Next(100001, 999999);

//Session["ValidCode"] = d;

TimeSpan ts = new TimeSpan(0, 0, 15, 00);//cookie有效作用时间

_cookie = new HttpCookie("ValidInfo");

_cookie.Expires = DateTime.Now.Add(ts);

_cookie.Values.Add("ValidCode", d.ToString());

_httpContext.Response.AppendCookie(_cookie);

BLL.EmailHelper.SendMail(d, loginInfo.DefaultMail, loginInfo.IsEnglish);

returnsData.MessageText = loginInfo.IsEnglish ? 0 : 1;

_httpContext.Response.Write(returnsData.MessageText);

_httpContext.Response.End();

}

}

}

/// 

/// 验证

/// 

public void Validation()

{

}

public bool IsReusable

{

get

{

return false;

}

}

}

}

------解决思路----------------------

json.ResponseText 试试

------解决思路----------------------

换一个JQ版本。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值