-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

1
  • "url": "http://localhost/fb-callback.php?post_id=<?= $uid ?>", see also here: stackoverflow.com/questions/2150238/… Commented May 8, 2019 at 6:12

2 Answers 2

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",
 ................
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, thats really helps me a lot... appreciate it :)
This is a bad coding practice.
0

Try This

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.