1

component.php

<script>
   jq142(document).ready( function() {
       new Paginator('<?php echo HOST_URL; ?>component_ajax.php');
});        
</script>

I need to pass the id from component.php file to component_ajax.php file. component_ajax.php will load on the component.php file.

component_ajax.php

$coid = $_GET['id'];
$products = $productObj->getFrontProductsbyComponents( $coid );

Explain me to that how to pass id to $coid?

9
  • 7
    new Paginator('<?php echo HOST_URL; ?>component_ajax.php?id="your id"'); Commented Oct 14, 2013 at 7:30
  • so you want to pass the $coid to the component.php Commented Oct 14, 2013 at 7:32
  • @user2877903 you should follow the Ruturaj Commented Oct 14, 2013 at 7:33
  • tried new Paginator('<?php echo HOST_URL; ?>component_ajax.php?id="your id"'); But it is not working. Commented Oct 14, 2013 at 7:33
  • This componet_ajax.php file loading using Ajax. Commented Oct 14, 2013 at 7:38

2 Answers 2

1

You need to append the id to the component_ajax.php URL.

new Paginator('<?php echo HOST_URL; ?>component_ajax.php?id=<?php echo $your_id; ?>');

If the ID you need to pass to component_ajax.php is in JavaScript instead of PHP, append the ID to the URL with javascript.

<script>
    var your_id = 123;
    jq142(document).ready( function() {
        new Paginator('<?php echo HOST_URL; ?>component_ajax.php?id=' + your_id);
    });
</script>
Sign up to request clarification or add additional context in comments.

4 Comments

What is displayed when you print_r($_REQUEST) inside component_ajax.php?
That tells me the id is not being passed at all (as opposed to being a blank value), which suggests maybe your Paginator javascript might be removing the id parameter from the URL. Can you tell me more about the Paginator javascript? Is it custom code or is it a third party library with documentation you could link to?
Pass the parameters in as an argument. var ajaxParams = {"id":<?php echo $your_id ?>}; new Paginator('<?php echo HOST_URL; ?>component_ajax.php', {"xParams": ajaxParams});
0

Pass the ID in to your Paginator object as an argument.

var ajaxParams = {"id":<?php echo $your_id ?>};
new Paginator('<?php echo HOST_URL; ?>component_ajax.php', {"xParams": ajaxParams});

Source

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.