What is ajax?
The ajax() method loads remote data through HTTP requests.
This method is the underlying AJAX implementation of jQuery. For simple and easy-to-use high-level implementations, see $.get, $.post, etc. $.ajax() returns the XMLHttpRequest object it created. In most cases you won't need to manipulate this function directly unless you need to manipulate less commonly used options for more flexibility.
In the simplest case, $.ajax() can be used directly without any parameters.
#Where are the results obtained from the ajax request?
success: The parameter is required to be Function type. The callback function called after the request is successful has two parameters.
(1) Data returned by the server and processed according to the dataType parameter.
(2) Describe the string of the state.
FUNCTION (Data, TextStatus) {
// Data may be XMLDOC, JSONOBJ, HTML, Text, etc.
#How to display the returned results?
Here is an example, page js code:
<script> //ajax页面刷新 function changeDept() { //var areaID = document.getElementById("areaId").value; //var types = 'PERSONAL'; $.ajax({ type : "post", dataType : "json", //url : "${path}/businessguide/findOrgByDivisionCode.action?divisionCode="+ areaID, success : function(data) { //方法一: var status = data.status; if (data.code == "0") { $(".weather").empty(); $(".weather").text("温度" + data.temp + "天气" + data.weather + "图标"+ data.weatherimg); } else { alert(data.status); } //方法二: var html=''; var status = data.status; if (data.code == "0") { $(".weather").empty(); html+='"温度" + data.temp + "天气" + data.weather + "图标"+ data.weatherimg'; $(".weather").append(html); } else { alert(data.status); } } }); } </script>
Page calling code:
<body> <span class="weather"> </span> </body>
The above is the detailed content of How to display data in ajax. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
