Home > Web Front-end > JS Tutorial > body text

用jquery存取照片的具体实现方法_jquery

WBOY
Release: 2016-05-16 17:30:48
Original
1155 people have browsed it

1.用jquery 调用aspx内的函数:

复制代码 代码如下:

sajax("***.aspx/DoSave",  //一个URL地址 ,指向函数所在的ASPX
    null,//参数, 所指向的ASPX的函数所需要的参数
    showSaveResult);//执行成功之后执行的jS脚本
 

2.函数 sajax
复制代码 代码如下:

function sajax(url, data, successcallback)
{   
  $.ajax({       
  type: "POST",       
  url: url,       
  data: data,       
  async: false,       
  contentType: "application/json;charset=utf-8",       
  dataType: "json",       
  success: successcallback,         
   statusCode: {           
      404: function () {                  alert('page not found');              },           
      500: function () {                  alert('内部服务器错误 ');              }       
  }   
});
 };
 


3.后台函数:
cs代码
复制代码 代码如下:

 [WebMethod(EnableSession = true)]   //AJAX调用的必须是 这种方式声明的函数   EnableSession--》用Session存取照片
public static void DoSave()
{
    byte[] byZhaoPian;              
try              
{                  
    byZhaoPian = (byte[])(HttpContext.Current.Session["image"]);              
}              
catch              
{                  
    byZhaoPian = new byte[0];              
}
****************
}
 

4.如何给Session["image"]赋值
用jquery存取照片的具体实现方法_jquery

选择好照片之后,点击确定上传的时候,把图片转换为二进制,赋值给Session["image"]

5.上传照片的方法这里就不在写了,请查看其它文章

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!