$.ajax({
type: 'post',
url: '../AshxHandler/HandlerAddPhoto.ashx',
data: { clientPath: photoName },
dataType: 'text',
cache: false,
success: function (data) {
alert(1);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert('上传图片出现错误!');
}
});
context.Response.ContentType = "application/json";
string clientPath = context.Request["clientPath"].ToString();
bool isExist = UploadFileHelper.UploadPhoto(clientPath, HttpContext.Current.Server.MapPath("~/UploadFile/oldimage/"));
context.Response.Charset = "UTF-8"; //设置字符集类型
context.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
context.Response.Write("success");
context.Response.End();

在IE下

dataType: 'text',一定要写,并且返回值的格式一定要正确,不然下面代码不会执行
success: function (data) {
alert(1);
},
String dataType
预期服务器返回的数据类型。如果不指定,jQuery 将自动根据 HTTP 包 MIME 信息来智能判断,比如XML MIME类型就被识别为XML。在1.4中,JSON就会生成一个JavaScript对象,而script则会执行这个脚本。随后服务器端返回的数据会根据这个值解析后,传递给回调函数。可用值:
"xml": 返回 XML 文档,可用 jQuery 处理。
"html": 返回纯文本 HTML 信息;包含的script标签会在插入dom时执行。
"script": 返回纯文本 JavaScript 代码。不会自动缓存结果。除非设置了"cache"参数。'''注意:'''在远程请求时(不在同一个域下),所有POST请求都将转为GET请求。(因为将使用DOM的script标签来加载)
"json": 返回 JSON 数据 。
"jsonp": JSONP 格式。使用 JSONP 形式调用函数时,如 "myurl?callback=?" jQuery 将自动替换 ? 为正确的函数名,以执行回调函数。
"text": 返回纯文本字符串
 

随机推荐

  1. 让IE下支持Html5的placeholder属性

    HTML5对Web Form做了许多增强,比如input新增的type类型.Form Validation等. Placeholder 是HTML5新增的另一个属性,当input或者textarea设 ...

  2. [转] - 经典SQL语句大全

    经典SQL语句大全 一.基础 1.说明:创建数据库CREATE DATABASE database-name 2.说明:删除数据库drop database dbname3.说明:备份sql serv ...

  3. javascript中的function

    function / 对象 所有的变量和方法名的:以字母,$ _开头其他随便,尽量使用英文字母命名,见名知意注意点:不允许使用关键字定义变量和方法的名称====函数即方法,方法即函数====百度:ja ...

  4. Repair duplicate IDs on cloned Endpoint Protection 12.1 clients

    https://support.symantec.com/en_US/article.TECH163349.html

  5. HDU 1698 线段树 区间更新求和

    一开始这条链子全都是1 #include<stdio.h> #include<string.h> #include<algorithm> #include<m ...

  6. centos7 设置中文

    查看系统版本[root@webtest76 ~]# cat /etc/redhat-releaseCentOS Linux release 7.0.1406 (Core) [root@localhos ...

  7. 返回指定的VC

    for (UIViewController *controller in self.navigationController.viewControllers) {            if ([co ...

  8. Yii源码阅读笔记(十八)

    View中的查找视图文件方法和渲染文件方法 /** * Finds the view file based on the given view name. * 通过view文件名查找view文件 * ...

  9. Overengineering

    https://en.wikipedia.org/wiki/Overengineering Overengineering (or over-engineering) is the designing ...

  10. rgb转灰度 RGB To Gray php Adobe RGB (1998) [gamma=2.20]

    <?php /** * Date: 2016/10/24 * Time: 0:52 */ // Gray = (R^2.2 * 0.2973 + G^2.2 * 0.6274 + B^2.2 * ...