Home  >  Article  >  Web Front-end  >  Things to note when transferring values ​​between pages

Things to note when transferring values ​​between pages

零下一度
零下一度Original
2017-06-27 09:31:551255browse

In JavaScript, you need to pay attention to the value transfer between pages.

For example, when we pass a number to the next page through the URL, it may be a string after being parsed on the next page. This will cause a phenomenon. When debugging, I found that the value I wanted to pass was indeed passed, but an error was reported on the page and the effect was not achieved. At this time, we need to convert this value. (For example: data="1234"; parseInt(data);)

jQuery ajax

In development, you have to deal with the background in many cases. Generally, when we get the value returned to us by the background, we need to pass some values ​​to the background. These will be written in the interface document, we need to read them clearly. Pay attention to the type of value passed. The interface document will state the data type you want to pass and the data type it passes to you. If you see these clearly, you will save a lot of debugging.

In order to apply the data passed from the background, we can perform some conversions on the data type. For example:

var obj = $.parseJSON('{"name": "Sage"}'); //jasn to object

alert(obj.name === " Sage");

When forming data into an array, you can use push

The above is the detailed content of Things to note when transferring values ​​between pages. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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