TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Santhosh Subramaniam
NA
226
108.8k
Load Image from handler using JQuery
May 6 2015 8:40 AM
Hi Frnds,
In my project i want to bind image from handler file(.ashx) in asp.net , i want to call that file in JQuery and bind image.
sample Code:
In .ashx file
public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "image/*.";
byte[] filecontent = File.ReadAllBytes(@"D:\Sample\LoadImageInAJAX\LoadImageInAJAX\Desert.jpg");
context.Response.BinaryWrite(filecontent.ToArray());
}
In .html File
$(document).ready(function () {
$.ajax({
url: "LoadImage.ashx",
type: "GET",
dataType: "binary",
processData: false,
success: function (result) {
var data = result;
// do something with binary data
},
error: function (xhr) {
alert("Error occurred while loading the image. "
+ xhr.responseText);
}
});
});
I got an error is responseText is : JFIF.
Please help me out.
Thanks in Advance.
Reply
Answers (
1
)
Quiz in C#
how do excel find in datagridview !?