首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

使用jquery ajax 不进ashx页面,这什么有关问题,

2012-08-16 
使用jquery ajax 不进ashx页面,这什么问题,急急急...前台C# code%@ Page LanguageC# AutoEventWireup

使用jquery ajax 不进ashx页面,这什么问题,急急急...
前台

C# code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="zt_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>    <script type="text/javascript">        $(function() {            $("#confirm").click(function() {                $.ajax({                    url: 'Handler.ashx',                    dataType: 'text',                    data: 'id=1',                    success: function(msg) {                        alert(msg);                    }                });            });        });    </script></head><body>    <form id="form1" runat="server">    <div>        <input type="button" value="确定" id="confirm" />    </div>    </form></body></html>


ashx页面
C# code
<%@ WebHandler Language="C#" Class="Handler" %>using System;using System.Web;public class Handler : IHttpHandler {        public void ProcessRequest (HttpContext context) {        context.Response.ContentType = "text/plain";        string x = context.Request.QueryString["id"].ToString();        context.Response.Write('x');    }     public bool IsReusable {        get {            return false;        }    }}

就是不进这个页面也不报错- -

[解决办法]
$.ajax({
url: 'Handler.ashx',
dataType: 'text',
data: 'id=1',
success: function(msg) {
alert(msg);
}
});
需要加一个属性。
 $.ajax({
url: 'Handler.ashx',
type:"GET",
dataType: 'text',
data: 'id=1',
success: function(msg) {
alert(msg);
}
});

[解决办法]
是不是缓存了?
url: 'Handler.ashx?tmp' + (new Date()).valueOf(),

热点排行