Home Web Front-end JS Tutorial The use of el expression in js and the non-empty judgment method

The use of el expression in js and the non-empty judgment method

May 28, 2018 pm 03:52 PM
javascript method expression

Below I will share with you an article about the use of el expressions in js and the non-empty judgment method. It has a good reference value and I hope it will be helpful to everyone.

Note, what I want to talk about here is not the use of nested el expressions in jsp, but the use in js.

Scenario:

After the page jumps, use spring mvc to pass a json object to the front-end page. After getting it in js, Do processing.

Returned json object:

{"nodes":[{"contactmobile":"15922208502","orderno":"XNH31918062989476864"},{"id":"12198","group":"11","content":"把考虑考虑","modelname":"Company"}],"links":[{"target":"12198","id":"15016","relationType":"公司","source":"12194"}]}
Copy after login

var graph; 
var flag = "${empty jsonData}"; 
if(flag!="true"){ 
  graph = eval('(' + '${jsonData}' + ')'); 
};
Copy after login

There is a note here:

When using el expressions in js, be sure to use quotation marks. If the returned json contains double quotes, then use single quotes to surround the el expression, otherwise, use double quotes.

In addition, pay attention to the writing method of using the eval function to convert the json string into an object.

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

AJAX verifies database content and displays the value on the page

Ajax cannot refresh data under IE9 Solution to caching problem

Use ajax technology to dynamically call Sina stock real-time data without refreshing

The above is the detailed content of The use of el expression in js and the non-empty judgment method. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel. How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel. Mar 28, 2024 pm 12:50 PM

How to write a novel in the Tomato Free Novel app. Share the tutorial on how to write a novel in Tomato Novel.

How to delete WeChat friends? How to delete WeChat friends How to delete WeChat friends? How to delete WeChat friends Mar 04, 2024 am 11:10 AM

How to delete WeChat friends? How to delete WeChat friends

How to enter bios on Colorful motherboard? Teach you two methods How to enter bios on Colorful motherboard? Teach you two methods Mar 13, 2024 pm 06:01 PM

How to enter bios on Colorful motherboard? Teach you two methods

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts) How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts) May 01, 2024 pm 12:01 PM

How to recover deleted contacts on WeChat (simple tutorial tells you how to recover deleted contacts)

Summary of methods to obtain administrator rights in Win11 Summary of methods to obtain administrator rights in Win11 Mar 09, 2024 am 08:45 AM

Summary of methods to obtain administrator rights in Win11

Detailed explanation of Oracle version query method Detailed explanation of Oracle version query method Mar 07, 2024 pm 09:21 PM

Detailed explanation of Oracle version query method

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed! Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed! Mar 23, 2024 am 10:42 AM

Quickly master: How to open two WeChat accounts on Huawei mobile phones revealed!

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs) May 04, 2024 pm 06:01 PM

The secret of hatching mobile dragon eggs is revealed (step by step to teach you how to successfully hatch mobile dragon eggs)

See all articles