js requested data

Discussion in 'JavaScript' started by vOlLvEriNe, Feb 14, 2014.

  1. #1
    Hi all, any method to get requested data like php like this
    dp.php?id=1&data=Wow
    so how can i get this in java script ?
    dp.js?id=1&data=Wow

    Thanks
     
    vOlLvEriNe, Feb 14, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    PoPSiCLe, Feb 14, 2014 IP
  3. vOlLvEriNe

    vOlLvEriNe Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    You are my good friend :)

    Bro I need js? get method not any external php file or something else
     
    vOlLvEriNe, Feb 14, 2014 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    I'm not sure what you need - is it an existing URL? Or a string?
    If it's an existing URL, you can use the suggestions in the link I showed you
    If it's a string, you can parse it, split it and do mostly whatever you want, based on standard javascript functionality.

    If you're using jQuery, there are some very simple functions you can use to get a current URL-parameter, like this:
    
      function GetURLParameter(sParam) {
        var sPageURL = window.location.search.substring(1);
        var sURLVariables = sPageURL.split('&');
        for (var i = 0; i < sURLVariables.length; i++)
        {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam)
        {
        return sParameterName[1];
        }
        }
       }
    
    Code (markup):
    which you use like:
    
    var urlID = getUrlParameter('id')
    var urlData = getUrlParameter('data');
    
    Code (markup):
     
    PoPSiCLe, Feb 14, 2014 IP
  5. vOlLvEriNe

    vOlLvEriNe Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    Dear I want to want This
    <script src="js/name.js?name=PoPSiCLe&platform=dp"></script>

    and js will create a a iframe

    <iframe src="//site.com/name.php?name=PoPSiCLe&platform=dp" />

    I hope now you can understand
     
    Last edited: Feb 14, 2014
    vOlLvEriNe, Feb 14, 2014 IP
  6. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #6
    In js/name.js

    document.write('<iframe src="//site.com/name.php' + window.location.search + '" />');
     
    ThePHPMaster, Feb 15, 2014 IP
  7. vOlLvEriNe

    vOlLvEriNe Member

    Messages:
    99
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    Ohh, I know that bro, but i want location in js file from js/name.js?name=PoPSiCLe&platform=dp bold text
     
    vOlLvEriNe, Feb 15, 2014 IP
  8. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #8
    Can you repost what you want to create what? My answer was based on the specs in the above comment. Seems to me it is not what you need?
     
    ThePHPMaster, Feb 15, 2014 IP