How to retrieve parameter passed in URL??

5 posts, 0 answers
  1. Adrian
    Adrian avatar
    6 posts
    Member since:
    Dec 2013

    Posted 02 Apr 2014 Link to this post

    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
  2. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 03 Apr 2014 Link to this post

    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.
     
  3. Adrian
    Adrian avatar
    6 posts
    Member since:
    Dec 2013

    Posted 03 Apr 2014 in reply to Anton Dobrev Link to this post

    Hi Anton,

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

    Thanks
  4. Anton Dobrev
    Admin
    Anton Dobrev avatar
    539 posts

    Posted 03 Apr 2014 Link to this post

    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.
     
  5. balmer
    balmer avatar
    1 posts
    Member since:
    Oct 2015

    Posted 29 Oct 2015 Link to this post

    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

     

     

Back to Top