-1

When i call /comment.php it returns data that i've requested. where post_id is fixed.

/comment.php

 "ajax":
{
 "url": "http://localhost/fb-callback.php?post_id=12345_67890",
   "type" : "GET",
"dataSrc":  function (response) { 
                // console.log(response);
                            if(response.whaterver == 0){
                               //DO YOUR THING HERE
                            }
                            //return back the response
                            return response; 
                        },

Instead of fixed id (12345_67890), i wanna declare a php variable there, something like this ::-

<?php
$uid = $_GET['uid'];
?>

 "ajax":
{
 "url": "http://localhost/fb-callback.php?post_id="+"&uid",
"type" : "GET",
 ................

so that when i'll call url /comment.php?uid=12345_67890** it'll return results. But it seems it doesn't work that way. HOW CAN I DO THAT Or is there other way to make this call ?

Here is the Full code ::: https://pastebin.com/iy3htv63

Anon
  • 3
  • 2
  • `"url": "http://localhost/fb-callback.php?post_id== $uid ?>",` see also here: https://stackoverflow.com/questions/2150238/php-variable-in-html-no-other-way-than-php-echo-var –  May 08 '19 at 06:12

2 Answers2

3

you can echo it on the ajax url. try this

 <?php
  $uid = $_GET['uid'];
?>

 "ajax":
{
 "url": "http://localhost/fb-callback.php?post_id=<?php echo $uid; ?>",
 "type" : "GET",
 ................
Syed mohamed aladeen
  • 6,507
  • 4
  • 32
  • 59
0

Try This

<?php
$uid = $_GET['uid'];
?>
var uid = <?php echo $uid; ?>;
 "ajax":
{
 "url": "http://localhost/fb-callback.php?post_id="+uid,
"type" : "GET",
 ................
SAVe
  • 814
  • 6
  • 22