麻烦帮看一下我这个jquery ajax查询为什么总是报错

ken080504 2012-06-19 10:27:29
$.ajax({
type: "POST",
url: "BusinessSearchHelper.ashx",
data: { star: starTiem, end: endTiem, acc: account, type: check },
datatype: "html",
success: function(ReturnData) {
$("#showData").html(ReturnData);
},
error: function(RetrunError) {
$("#showData").html(RetrunError);
}
});


BusinessSearchHelper.ashx里面的代码



using System;
using System.Web;
using STBKen.BLL;
using STBKen.Entity;
using System.Text;
using System.Collections.Generic;

public class BusinessSearchHelper : IHttpHandler {

string starTime;
string endTime;
string account;
string type;
BLLOperator bll = new BLLOperator();
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
starTime = context.Request.Params["star"].ToString().Trim();
endTime = context.Request.Params["end"].ToString().Trim();
account = context.Request.Params["acc"].ToString().Trim();
type = context.Request.Params["type"].ToString().Trim();

List<Entity_CLP> LSclp = bll.SearchCPL_BLL(starTime,endTime,account,0,20);
StringBuilder sb = new StringBuilder();
foreach(Entity_CLP clp in LSclp)
{
sb.Append("<Table>");
sb.Append("<tr>");
sb.Append("<td>"+clp.Account+"</td>");
sb.Append("<td>" + clp.Clpno + "</td>");
sb.Append("<td>" + clp.La_no + "</td>");
sb.Append("<td>" + clp.Recla_date + "</td>");
sb.Append("<td>" + clp.Xingqi + "</td>");
sb.Append("<td>" + clp.Client + "</td>");
sb.Append("<td>" + clp.So_no + "</td>");
sb.Append("<td>" + clp.Rec_date + "</td>");
sb.Append("<td>" + clp.XingqiSO + "</td>");
sb.Append("<td>" + clp.Tocbm + "</td>");
sb.Append("</tr>");
sb.Append("</Table>");
}
context.Response.Write(sb.ToString());
}



public bool IsReusable {
get {
return false;
}
}
...全文
104 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Ahoo 2012-06-19
  • 打赏
  • 举报
回复
朋友,你这是报的什么错。
ken080504 2012-06-19
  • 打赏
  • 举报
回复
没改前是报:object Object

后来我改成如下代码:
error: function(XMLHttpRequest, messges) {
alert(messges);
}
报:error



三石-gary 2012-06-19
  • 打赏
  • 举报
回复
报什么错误。。错误信息
三石-gary 2012-06-19
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
data: { star: starTiem, end: endTiem, acc: account, type: check },
这是发问题的时候大错的?
[/Quote]
看错了。。忽略它
三石-gary 2012-06-19
  • 打赏
  • 举报
回复
data: { star: starTiem, end: endTiem, acc: account, type: check },
这是发问题的时候大错的?
ken080504 2012-06-19
  • 打赏
  • 举报
回复
总是提示error
ken080504 2012-06-19
  • 打赏
  • 举报
回复
error:参数有以下三个:XMLHttpRequest 对象、错误信息、(可选)捕获的错误对象。如果发生了错误,错误信息(第二个参数)除了得到null之外,还可能是"timeout", "error", "notmodified" 和 "parsererror"。


这是我在网上查到的,但是总是得不到真正的错误信息
ken080504 2012-06-19
  • 打赏
  • 举报
回复
error里不是有几个参数吗?第二个是错误信息(网上查的)我只是直接把那个参数信息读出来。具体我也不怎么会用,所以问问大家
原因分析: 在transport.js文件中,大概 580行到590行之间,这个句用于格式化json,他重写了object的结构,导致于js框架冲突。冲突的原因是jquery给一个object增加了很多元素,那么在Object.prototype.toJSONString = function () 这个函数中 for (k in this) 语句中进行了无数次的循环,导致网页很卡,并且在IE中会报错。 解决方案: 根本的解决办法是不用transport.js中的json功能,那么就要有一个相同的功能来代替它,这里我选用jquery-json1.3.js。首先要把transport.js中的json功能删除。由于实现json功能的函数有区别,所以要麻烦改掉原ecshop中各个地方用到的toJSONString()函数。 解决步骤: 1. 下载附件中的js附件,并替换掉原文件。(主要去掉了transport.js的json功能并新增新的json功能) 2. page_header.lbi 中添加 {insert_scripts files='jquery.js,jquery.json-1.3.js'} 3. 在所有的JS中。 替换 *.toJSONString() 为 $.toJSON(*) 替换 *.parseJSON() 为 $.evalJSON(*) 替换(不是去掉)页面所有的$(){}函数,防止jquery不生效(解释:这一步是要替换掉原ecshop里的$(){}这个函数,因为它与jquery是冲突的,解决的办法很多,可以用其他函数代替,比如getId(){}等等,也可以用jquery本身来解决,在此,我就不具体做例子了,由于最近比较忙,好多天没研究ecshop了。^_^ .还有一个解决办法,大家自行研究吧: jQuery.noConflict() 运行这个函数将变量$的控制权让渡给第一个实现它的那个库。 这有助于确保jQuery不会与其他库的$对象发生冲突。 在运行这个函数后,就只能使用jQuery变量访问jQuery对象。例如,在要用到$("div p")的地方,就必须换成jQuery("div p")。 注意:这个函数必须在你导入jQuery文件之后,并且在导入另一个导致冲突的库之前使用。当然也应当在其他冲突的库被使用之前,除非jQuery是最后一个导入的。 ) 注意:可能要替换掉很多地方,请大家不要怕麻烦 解决范例: 1.在商品浏览页,用户评论这里: Ajax.call('comment.php', 'cmt=' + cmt.toJSONString(), commentResponse, 'POST', 'JSON'); 替换为 Ajax.call('comment.php', 'cmt=' + $.toJSON(cmt), commentResponse, 'POST', 'JSON'); 2.index.js 里 var res = result.parseJSON(); 替换为 var res = $.evalJSON(result); 以下是修改过的文件: js\compare.js \js\common.js \js\transport.js \themes\modify\library\member_info.lbi \admin\js\selectzone.js \admin\templates\topic_edit.htm \admin\templates\menu.htm \admin\templates\topic_edit.htm http://www.yodye.com/

52,787

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧