简体   繁体   中英

Why do we need to append data to URL

There are 2 ways that data is appended to URL (atleast that's what I am aware of, there can be more ways)

  1. Http get method
  2. .serialize()

Both of them append data to the url and are mostly used in forms . But I want to know what is the use of appending data to the url? In what cases will I need to append USER data to the URL? If there are cases and advantages, I can make use of them but I cant think of a reason for exposing user data through url from a form.

The easy response is for ease of bookmarking.

Say for example you have searched for a flight on a website and you want to save the results for later or send them to a friend.

Sending them www.flightpub.com wont help, but sending www.flightpub.com?destination=somewhere&source=nowhere&airline=planesRus will allow them to run the same search as you without having to refill all the form data.

Of course you don't want to do this for secure information, there are other ways for that, and you also have a rather small size limitation of when using GET , see here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM