jQuery AJAX and HttpHandlers in ASP.NET
https://www.codeproject.com/Articles/170882/jQuery-AJAX-and-HttpHandlers-in-ASP-NET
Introduction
In this article, we will see how we can make use of the jQuery library to make AJAX calls in ASP.NET with the help of HTTPHandlers. We will also see the use of JSON (JavaScript Object Notation) which is a format describing name/value pairs in a structured manner.
Asynchronous JavaScript and XML (AJAX) is a method which we can use to exchange data with the server without reloading the complete page.
jQuery is a JavaScript library which makes it easier to manipulate and navigate DOM elements in a web page. It also helps in implementing AJAX in rapid web application development. Currently, we have Intellisense support for jQuery in Visual Studio 2008/2010.
HTTPHandler is a process which returns data when its URL is called. The returned data can be anything from a simple string to data formats like JSON or XML.
Prerequisite
Download the latest version of jQuery from the jQuery site (http://jquery.com/). In Visual Studio 2010, it is added by default when a new web application is created.

Example: Making a Simple AJAX Call
In this example, we will make a simple AJAX call with the help of the jQuery.ajax API to an HTTPHandler.
The response from the HTTPHandler will be the JSON response which is then updated in the web page.
JavaScript Object notation (JSON) is a format of key/value pairs to store data.
It’s easy to consume in JavaScript and compact than XML. So let’s start with creating a handler page.
public void ProcessRequest (HttpContext context) {
string method = context.Request.QueryString["MethodName"].ToString();
context.Response.ContentType = "text/json";
switch (method)
{
case "GetData" :
context.Response.Write(GetData());
break;
}
}
protected string GetData()
{
return (@"{""FirstName"":""Ravi"", ""LastName"":""Baghel"",
""Blog"":""ravibaghel.wordpress.com""}");
}
As you can see, we are simply putting a response of JSON type with sample data.
In order to demonstrate passing a parameter to a handler, I have used the querystring methodname which will simply switch to the method you want to execute.
jQuery AJAX and HttpHandlers in ASP.NET的更多相关文章
- jQuery Ajax传递数组到asp.net web api参数为空
前端: var files = []; files.push({ FileName: "1.jgp", Extension: ".jgp", FileType: ...
- [转]jQuery AJAX pagination plugin with ASP.NET Server Side
本文转自:http://do-web.com/jpaging/usage How does it work? 1. In order to implement the plugin, you need ...
- jQuery AJAX Call for posting data to ASP.Net page ( not Get but POST)
the following jQuery AJAX call to an ASP.Net page. $.ajax({ async: true, type: "POST", url ...
- ASP.NET使用jQuery AJAX实现MD5加密实例
一个asp.net ajax例子,使用jquery,实现md5加密.在.NET 4.0,Visual Studio 2010上成功运行. 效果体验:http://tool.keleyi.com/t/m ...
- [转]JQuery Ajax 在asp.net中使用总结
本文转自:http://www.cnblogs.com/acles/articles/2385648.html 自从有了JQuery,Ajax的使用变的越来越方便了,但是使用中还是会或多或少的出现一些 ...
- jQuery Ajax 方法调用 Asp.Net WebService 以及调用aspx.cs中方法的详细例子
一.jQuery Ajax 方法调用 Asp.Net WebService (引自Terry Feng) Html文件 <!DOCTYPE html PUBLIC "-//W3C//D ...
- ASP.NET jquery ajax传递参数
第一种:GET传递 前台 ajax GET 传递 :即在请求的地址后面加上参数,URL地址长度有显示,安全性低 后台接收:Request.QueryString[“参数名字”]! 例如: func ...
- JQuery Ajax 在asp.net中使用小结
自从有了JQuery,Ajax的使用变的越来越方便了,但是使用中还是会或多或少的出现一些让人短时间内痛苦的问题.本文暂时总结一些在使用JQuery Ajax中应该注意的问题,如有不恰当或者不完善的地方 ...
- asp.net 中使用JQuery Ajax 上传文件
首先创建一个网页,网页中添加如下代码. <h3>Upload File using Jquery AJAX in Asp.net</h3> <table> < ...
随机推荐
- Mac017--Jenkins 持续集成
Jenkins 是一个开源项目,提供了一种易于使用的持续集成系统,使开发者从繁杂的集成中解脱出来,专注于更为重要的业务逻辑实现上.同时 Jenkins 能实施监控集成中存在的错误,提供详细的日志文件和 ...
- ECharts-第一篇最简单的应用
1.简单演示一个饼状图 准备好echarts-all.js 2.编写页面代码 <!DOCTYPE html> <html> <head> <meta char ...
- HDU 6070题解(二分+线段树)
题面 传送门 此题的题意不是很清晰,要注意的一点是在区间[L,R]中,默认题目编号最后一次出现的时候是AC的 比如1 2 1 2 3 ,在区间[1,4]中,第3次提交时AC第1题,第4次提交时AC第2 ...
- make: *** 没有指明目标并且找不到 makefile
make: *** 没有指明目标并且找不到 makefile. 停止. make: *** 没有规则可以创建目标“install”. 停止. 不是没有makefile文件,而是你没有安装gcc编译 ...
- k8s结合helm部署
一.安装Helm helm教程以及安装可以参考这篇文章 二.Heml说明 常见的helm模板如下 myapp - chart 包目录名 ├── charts - 依赖的子包目录,里面可以包含多个依赖的 ...
- 关于使用itext转Html为pdf添加css样式的问题
使用的jar文件 xmlworker-5.5.11.jar itextpdf-5.5.11.jar 下载地址:https://pan.baidu.com/s/1i5AIBvZ 以下为测试代码 pack ...
- openstack stein部署手册 7. nova-compute
# 安装程序包 yum install -y openstack-nova-compute # 变更配置文件 cd /etc/nova mv nova.conf nova.conf.org cat & ...
- shell 搜索指定目录下所有 jar 文件生成csv文件
虽说比较简单,但希望分享给大家.按需求改成想找的:例如txt,xls 等. 脚本名 扫描的路径 文件名 testFind.sh / testFind.txt (如果未配置环境变量 ./testFi ...
- rabbit例子
https://blog.csdn.net/csm201314/article/details/76377214 #include <SimpleAmqpClient/SimpleAmqpCli ...
- springboot+UEditor图片上传
springboot+UEDitor百度编辑器整合图片上记录于此 1.下载ueditor插件包,解压到static/ueditor目录下 2.在你所需实现编辑器的页面引用三个JS文件 1) uedi ...