究竟是什么Ajax请求?它与Servlet请求不同吗? [英] What exactly is Ajax request? Is it different from Servlet Request?

查看:237
本文介绍了究竟是什么Ajax请求?它与Servlet请求不同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我。究竟是什么Ajax请求?它是否与Servlet请求不同?

解决方案

Ajax调用是由浏览器发起的异步请求,不会直接导致页面转换。 servlet请求是Java特定术语(servlet是Java规范),用于为可能获得简单GET或POST(等)或Ajax请求的HTTP请求提供服务。



Ajax(异步Javascript和XML)请求有时被称为XHR请求(XmlHttpRequest),这是大多数浏览器为用于发送Ajax请求的对象提供的名称,因为至少最初的Ajax调用涉及发送并且接收XML但现在发送/接收JSON,纯文本或HTML也是如此。



Ajax请求的一个很好的例子是Stackoverflow上的注释系统。您可以在文本框中输入注释,然后单击提交。它不会提交整个页面(就像传统的HTML表单提交一样,通常会转换为POST但有时会转换为GET HTTP请求)。相反,浏览器可能会通过XHR向服务器发送POST请求,并被通知响应(因此异步)。但是服务器通常无法区分Ajax请求或页面转换,因为两者都只是归结为HTTP请求。


can anyone tell me. What exactly is Ajax request? Is it different from Servlet Request?

解决方案

An Ajax call is an asynchronous request initiated by the browser that does not directly result in a page transition. A servlet request is a Java-specifc term (servlets are a Java specification) for servicing an HTTP request that could get a simple GET or POST (etc) or an Ajax request.

An Ajax ("Asynchronous Javascript and XML") request is sometimes called an XHR request ("XmlHttpRequest"), which is the name most browsers give the object used to send an Ajax request, because at least initially Ajax calls involved the sending and receiving of XML but now it's just as common to send/receive JSON, plain text or HTML.

A good example of an Ajax request is the comment system on Stackoverflow. You can enter a comment in the textbox and click submit. It doesn't submit the whole page (like a traditional HTML form submission would, which translates into usually a POST but sometimes a GET HTTP request). Instead the browser will send probably a POST request via XHR to the server and be notified of the response (hence "asynchronous"). But the server typically can't distinguish between an Ajax request or a page transition because both simply come down to HTTP requests.

这篇关于究竟是什么Ajax请求?它与Servlet请求不同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆