Spring MVC+Ajax创建实例
Java代码
@Override
protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object cmd,
BindException ex) {
String userId=request.getParamater("userId");
Map userInfoMap=userDao.getUserBaseInfo(userId);
JSONObject object = new JSONObject();
object.put("userInfoMap",userInfoMap);
response.setContentType("text/Xml;charset=gbk");
PrintWriter out = null;
try {
out = response.getWriter();
out.println(object.toString());
}
catch (IOException ex1) {
ex1.printStackTrace();
}finally{
out.close();
}
return nu
相关文档:
大家先看一段简单的jquery ajax 返回值的js
代码
function getReturnAjax{
$.ajax({
type:"POST",
url:"ajax/userexist.aspx",
data:"username="+vusername.value,
success:function(msg){
&nb ......
What is AJAX
This section is for those who have no idea what AJAX is. If you don’t fall into this category, feel free to skip to the next section.
AJAX stands for asynchronous JavaScript and XML. If you see another term XHR, which is shorthand for XML HTTP request, it’s the same thing. ......
对于很多 Web 开发人员来说,只需要生成简单的请求并接收简单的响应即可;但是对于希望掌握 Ajax 的开发人员来说,必须要全面理解 HTTP 状态代码、就绪状态和 XMLHttpRequest 对象。在本文中,Brett McLaughlin 将向您介绍各种状态代码,并展示浏览器如何对其进行处理,本文还给出了在 Ajax 中使用的比较少见的 HTTP 请求。 ......
ajax.open方法中,第3个参数是设同步或者异步。prototype等js类库一般都默认为异步,即设为true。
先说下同步的
情况下,js会等待请求返回,获取status。不需要onreadystatechange事件处理函数。
而异步则需要
onreadystatechange事件处理,且值为4再正确处理下面的内容
......
Ajax的无刷新分页
这里以两个文件进行代码显示一个是ajax分页实现的文件,另一个是分页类文件
文件1.ajax_page.php
<script type="text/javascript" language="javascript">
function createXMLHttp()
{
var browser=navigator.appName; //get the current browser
......