mvc 中 JSON,ajax
2017-08-14 14:23
253 查看
public JsonResult getimgsize()
{
var res = new JsonResult();
returnData products
4000
= new returnData();
products.uploadedSize = 0;
res.Data = products;
res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。
return res;
}
view-----------------
var url = urls + 'Upimg03/getimgsize?ran=' + Math.random();
var uploadedSize = 0;
$.ajax({
url : url,
data: "fileName=" + file.name + "&lastModifiedDate=" + file.lastModifiedDate.getTime(),
async : false,
type : 'POST',
success: function (returnData) {
//returnData = JSON.parse(returnData);
// alert('服务器返回的尺寸'+returnData.uploadedSize);
uploadedSize = returnData.uploadedSize;
}
});
{
var res = new JsonResult();
returnData products
4000
= new returnData();
products.uploadedSize = 0;
res.Data = products;
res.JsonRequestBehavior = JsonRequestBehavior.AllowGet;//允许使用GET方式获取,否则用GET获取是会报错。
return res;
}
public byte[] StreamToBytes(Stream stream) { byte[] bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 stream.Seek(0, SeekOrigin.Begin); return bytes; }
view-----------------
var url = urls + 'Upimg03/getimgsize?ran=' + Math.random();
var uploadedSize = 0;
$.ajax({
url : url,
data: "fileName=" + file.name + "&lastModifiedDate=" + file.lastModifiedDate.getTime(),
async : false,
type : 'POST',
success: function (returnData) {
//returnData = JSON.parse(returnData);
// alert('服务器返回的尺寸'+returnData.uploadedSize);
uploadedSize = returnData.uploadedSize;
}
});
相关文章推荐
- Asp.net Mvc Ajax JsonResult简单使用
- Spring MVC Maven 使用ajax传json数据
- Asp.net Mvc Ajax JsonResult简单使用
- springmvc + json + js + ajax 数据交互
- SpringMVC ajax JSON 中文乱码问题
- asp.net mvc框架中,ajax传递json对象,并自动转换成参数对象的方法
- SpringMVC+ajax+json
- SpringMVC+json+ajax
- Ajax+SpringMVC传递JSON数组
- ASP.NET MVC + jQuery + Newtonsoft.Json 快樂的AJAX
- 【ajax系列】Spring4 mvc配置JSON返回
- SpringMvc+Ajax+json
- Spring 3.2.* MVC通过Ajax获取JSON数据报406错误
- MVC-Ajax-jquery分页 (服务器返回一个json数据,客户端解析)
- MVC3/4项目开发中遇到的ajax提交Json数据到后台Controller处理(接收参数:多重JSON)
- Spring 3.2.* MVC通过Ajax获取JSON数据报406错误
- XingXingMVC Ajax与JSON
- 架构师 传统三层+EF+linq+MVC+wcf+Repository+easyui+ajax+jquery+json 角色权限模块路由
- springmvc+ajax+json从页面传数据到后台,以及后台传Map集合到ajax解析
- ASP.NET MVC + jQuery + Newtonsoft.Json 快樂的AJAX