Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
'get' variables in easytabs loaded by ajax

Normaly in php I can use variables passed in like this:

http://localhost:88/myapp/mypage.php?id=552200

$_GET['id'];

I now switched a page to use easytabs (https://os.alfajango.com/easytabs/)

The tabs are initialized on index.php, wich has 2 tabs, page1.php and page2.php in index.php, I have this code to initialize the tabs:

jQuery(function($) {

  var container = $('#ajax-tab-container');

  container.easytabs({
    animate: false,
    cache: false,
    updateHash: true,
    defaultTab: $('#selectedTab').val()
  }).bind('easytabs:after', function(event, $clicked, $targetPanel, response, status, xhr) {
    $('input, textarea, select, button', $('.disable-fields')).prop('readonly', true).prop('disabled', true);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://rawgit.com/JangoSteve/jQuery-EasyTabs/master/lib/jquery.easytabs.js"></script>

<div id="ajax-tab-container" class='tab-container'>

  <ul class='etabs'>
    <li class='tab'>
      <a href="Verloop_meldingen.php" data-target="#tab-1">Verloop meldingen</a>
    </li>
    <li class='tab'>
      <a href="openstaande_meldingen.php" data-target="#tab-2">Openstaande meldingen</a>
    </li>
  </ul>

  <div class='panel-container'>
    <div id="tab-1"></div>
    <div id="tab-2"></div>
  </div>
</div>

The problem I have is that in index.php the $_GET variables are available, but in the pages that are loaded in the tabs, they are not.

Any idea how I can get the variables in the subpages?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

In the a href's you can just pass the id like you normally would

like so:

 <a href="Verloop_meldingen.php?id=1" data-target="#tab-1">Verloop meldingen</a> 
 <a href="openstaande_meldingen.php?id=1" data-target="#tab-2">Openstaande meldingen</a>

in your other pages you can get the variables like you normally would with $_GET

if you need this to change dynamicly you can use javascript to change the href like so:

$('yourhref selector class/id here').attr('href', 'new href');
over 4 years ago · Santiago Trujillo Report

0

I usually like to use a script like this to harvest the get variables in a javascript page for me.

It allows me to simply do get('paramname','somedefaultvalueifiwantto') to get the variable value I want from the get parameters. Just insert the script(without the console.log) part into your header, and you'll have a nice get function.

var some_get = get('open_tab','first-tab');

If you can suffice with a hash you can use document.location.hash to get the has value very quickly you need.

+(function(document) {
  function processGet() {
  var $get = {};
  var $rest = document.location.href
      .replace(document.location.hash,'')
      .replace(document.location.protocol+'//','')
      .replace(document.location.host,'')
      .replace(document.location.pathname,'');
  if (!($rest.trim().length === 0) && $rest.indexOf('?') === 0) {
     $rest = $rest.substring(1);
     if($rest.trim().length > 0) {
         var $roughGet = $rest.split('&').map(function($paramSet,$index, $array) {
                                                  var $set = $paramSet.split('=');
                                                  if($set.length == 1) {
                                                      $set[1] = null;
                                                  }
                                                  var value = $set[1] ? decodeURIComponent($set[1]) : null;
                                                  return {'key': decodeURIComponent($set[0]),'value' : value};
                                                });
         
           for(var c=0;c<$roughGet.length;c++) {
                 var $key = $roughGet[c].key;
                 var $value = $roughGet[c].value;
                 $get[$key] = $value;
           }

       }
      }
      return $get;
  }
  
  var GET = processGet();
  window.get = function(param, defaultValue) {
      var value = null;
      if(GET.hasOwnProperty(param)) {
          value = GET[param];
      }
      if(value === null) {
          if(defaultValue === undefined) {
              return value;
          }
          else {
              return defaultValue;
          }
      }
      return value;
  };
})(document)

console.log(get('foo','no'));

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!