We will be using the JavaScript's built in function split() which splits the string from a separator which is passed as a parameter to this function. The result is stored as an array and we will be using it multiple times since we want to split data into key value pairs, as the server generally processes it.
Just have a look at the following simple code.
URL will be split into parts based on the type of separators you are given in the function.
In this example we gave ('?', '&')
In forEach loop we are checking for the key and value pairs.
Those should be
key1 = firstValue
value1 = name
key2 = secondValue
value2 = email
We are alerting the result that generated here.
For any queries please comment in the bellow comment section.
For more interesting and useful code snippets please follow our blog.
Wow that was odd. I just wrote an extremely long comment but after I clicked submit my comment didn't appear. Grrrr... well I'm not writing all that over again. Anyways, just wanted to say wonderful blog! bloom box
ReplyDeleteHmm is anyone else experiencing problems with the images on this blog loading? I'm trying to figure out if its a problem on my end or if it's the blog. Any feedback would be greatly appreciated. relex smile
ReplyDelete