Jump to content

Jquery and php passing variable


claro

Recommended Posts

How can I rewrite my code below if my 'data_select.php' is in a variable $data = dataselect, that when it is set to true the data_select.php will show. I'm making a dynamic content in php and I'm not familiar with jquery. Any idea? thank you in advance.

<script type="text/javascript">
 $(document).ready(function() {
   $('a').click(function(){
     $.get('data_select.php', {'page':$(this).text()}, function(data){
       $('#content').html(data);
     });                         
   });
});
  </script>

 

When I try firebug, the error says 'data_select.php' not found.

Link to comment
https://forums.phpfreaks.com/topic/273684-jquery-and-php-passing-variable/
Share on other sites

Ok. thank you for pointing that out. I'll try my best to explain it further.

 

I have this page called lab_list.php

<li><a href='home.php?mountlab=viewLab' target = _top>Laboratories</a></li>
<li><a href='home.php?mountlab=setLab' target = _top>Mount Lab</a></li>

 

and it will go to my home.php

if(isset($_GET['action']) )
   {
      $test = $_SERVER['DOCUMENT_ROOT'].'/devices/device_coffin';
   }
   else if (isset($_GET['mountlab']))
   {
       $test = $_SERVER['DOCUMENT_ROOT'].'/lab/lab_coffin';  
   }
   else
   {
        $test = $_SERVER['DOCUMENT_ROOT'].'/welcome'; 
   }

 

and pass me in lab_coffin.php. In this page, I have to columns, the sidebar and its content.

What ever option in my sidebar, it's action will display in the content.

 

 

if  (($_GET['mountlab']) == "setLab") {
$test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/lab_add.php';
}else if  (($_GET['mountlab']) == "setLabAct") {
$test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/lab_addaction.php';
}else if  (($_GET['mountlab']) == "setLabact2") {
$test = $_SERVER['DOCUMENT_ROOT'].'/lab/set/data_select.php';
}

 

So when I clicked the mount lab in my list, it will pass me a page where I can select

another options.

 

In this page there is a transaction where I'm using jquery ajax..I tried it in a single page and it went well.

Now when I try to integrate with my dynamic content, I'm lost.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.