user2877903
user2877903

Reputation: 17

Passing values through URL

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?

Upvotes: 1

Views: 198

Answers (2)

emarref
emarref

Reputation: 1311

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

Upvotes: 0

emarref
emarref

Reputation: 1311

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>

Upvotes: 1

Related Questions