Ajax responseText parses json data case study

Ajax responseText parses json data case study

Solve the problem that the responseText returned by the server after ajax processing is JSON data.

First, the contents of the file in json format are as follows:

{
    "city":"ShangHai",  
    "telephone":"123456789"
}

Second, the json data returned by the server is the above content in responseText. Now we need to get it out. There are two ways:

Method 1:

var json = JSON.parse(request.responseText);  

alert(json.city);

Method 2:

var result = request.responseText;  

var jsonObject = eval("("+result+")");  

alert(jsonObject.telephone);

This is the end of this article about the detailed case of Ajax responseText parsing json data. For more related Ajax responseText parsing json data content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • The responseText in Ajax returns a page instead of a value
  • How to solve the problem of garbled responseText of ajax
  • JSON, AJAX, Maven Basics
  • Ajax login verification implementation code
  • Ajax realizes the linkage between provinces, cities and districts
  • Preliminary implementation of Ajax (using vscode+node.js+express framework)

<<:  Detailed explanation of the installation and configuration process of mysql8.018 on linux

>>:  Nginx prohibits direct access via IP and redirects to a custom 500 page

Recommend

How to set process.env.NODE_ENV production environment mode

Before I start, let me emphasize that process.env...

MySQL learning record: bloody incident caused by KEY partition

Demand background Part of the data in the busines...

Mysql modify stored procedure related permissions issue

When using MySQL database, you often encounter su...

Implementation of services in docker accessing host services

Table of contents 1. Scenario 2. Solution 3. Conc...

Tutorial on installing mysql5.7.23 on Ubuntu 18.04

This article shares with you the specific method ...

MySQL time types and modes details

Table of contents 1. MySQL time type 2. Check the...

How to set up a shared folder on a vmware16 virtual machine

1. Set up a shared folder on the virtual machine:...

CSS to achieve the effect of rotating flip card animation

The css animation of the rotating flip effect, th...

Summarize the common application problems of XHTML code

<br />For some time, I found that many peopl...

Best way to replace the key in json object

JSON (JavaScript Object Notation, JS Object Notat...

The whole process of IDEA integrating docker to deploy springboot project

Table of contents 1. IDEA downloads the docker pl...

Docker link realizes container interconnection

Table of contents 1.1. Network access between con...