How to Use jquery to access photos _ jquery

Source: Internet
Author: User
This article introduces how to use jquery to access photos. For more information, see 1. Use jquery to call functions in aspx:

The Code is as follows:


Sajax ("***. aspx/DoSave", // a URL address pointing to the ASPX of the Function
Null, // parameter, the parameter required by the ASPX Function
ShowSaveResult); // jS script executed after successful execution


2. Function sajax

The Code is as follows:


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 ('internal server error ');}
}
});
};



3. Background functions:
Cs code

The Code is as follows:


[WebMethod (EnableSession = true)] // AJAX must call the declared function EnableSession in this way -- use Session to access the photo
Public static void DoSave ()
{
Byte [] byZhaoPian;
Try
{
ByZhaoPian = (byte []) (HttpContext. Current. Session ["image"]);
}
Catch
{
ByZhaoPian = new byte [0];
}
****************
}


4. How to assign values to Session ["image "]

After selecting the photo, click "OK" to convert the image to binary and assign the value to Session ["image"].

5. The method for uploading photos is not written here. Please refer to other articles.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.