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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.