Phoenix Phoenix - 7 months ago 26
Ajax Question

Need help to fetch data from a URL parameter using Ajax or Java Script

I need to get the data in a URL parameter and assign it in a LABEL in another page...

The URL is : http://localhost:60391/pages/reservations.html?3

I need to fetch that 3 and assign it to Label in my webpage with ID #TestLabel.

Can anyone help me with a Java Script/ Ajax to make this possible?


This should do it:

var parts = document.location.href.split("?");
if (parts.length === 2) {
    document.getElementById("TestLabel").textContent = parts[1];