This is a migrated thread and some comments may be shown as answers.

How to retrieve parameter passed in URL??

4 Answers 622 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Adrian
Top achievements
Rank 1
Adrian asked on 02 Apr 2014, 07:44 PM
Hi, I am trying to pass and Id to a page through the url like below

aTag.setAttribute('href',"#page-home?uid=" + data.result[i].Id);

The id is being set but how do i then retrieve that Id from the url??

Thanks,

Adrian

4 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 03 Apr 2014, 08:05 AM
Hi Adrian,

Could you please specify what kind of application are you building - is it an AppBuilder app built with Kendo UI Mobile, jQuery Mobile, etc., or a web application? Parsing a query string is somewhat a generic task with JavaScript.

For example, in a web application, you can parse the query string from the URL in a similar way:
var currentId = (window.location.href.split('='))[1];

Kendo UI framework will pass an event when the view is loaded, for example in the show event. Please, refer to the following:
var currentId = e.view.params.uid;

Please, let us know if you have further questions.

Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
Adrian
Top achievements
Rank 1
answered on 03 Apr 2014, 08:54 AM
Hi Anton,

Sorry it is a JQuery Mobile template that I started the application with

Thanks
0
Anton Dobrev
Telerik team
answered on 03 Apr 2014, 09:23 AM
Hi Adrian,

Thanks for specifying, the previous suggestions remain valid, and there is also a portion of utility methods in the jQuery mobile API, along with a ParseUrl() method. When obtaining the search segment of the URL (the substring after the '?' char) you can parse it. There are a lot of community threads on this, for example this one.


Regards,
Anton Dobrev
Telerik
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
0
balmer
Top achievements
Rank 1
answered on 29 Oct 2015, 05:48 AM

try this .....

function getQueryVal(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}

Full Source : http://www.corelangs.com/js/basics/query.html

Balmer

 

 

Tags
General Discussion
Asked by
Adrian
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Adrian
Top achievements
Rank 1
balmer
Top achievements
Rank 1
Share this question
or