将信息从Jquery发送到服务器上的Php文件以搜索SQL数据库

I have this code located on the server in a php file

<?php
include "db.php";
$data=array();
$idFacebook=$_POST['idFacebook'];

$q=mysqli_query($con,"select `gender` from `users` where 
`idFacebook`='$idFacebook'");
while ($row=mysqli_fetch_object($q)){
 $data[]=$row;
}
echo json_encode($data);

?>

I have this code on my website

$(document).ready(function() {
    var url = "http://xxxxxxxxx.com/calGetBackupJSON.php";
    $.getJSON(url, {idFacebook: 11111111111}, function(result) {
        console.log(result);

    });
});

Currently, I can manually change the idFacebook on the server and it returns the correct info. BUT How do I pass the idFacebook from the web page to server? So it only returns one specific user's gender?

Thank you very much

Add a HTML input Eg <input type="text" id="idFacebook" /> and a button <button id="submitIDFB"></button> in your web page.

Change your JS content:

$('#submitIDFB').click(function(e) {
    e.preventDefault();
    var idFacebook = $('#idFacebook').val();
    var url = "http://xxxxxxxxx.com/calGetBackupJSON.php";
    $.getJSON(url, {idFacebook: idFacebook}, function(result) {
        console.log(result);

    });
});

You may do some data validation / data preparation first. :D

UPDATED:

If you want to handle error, use AJAX:

$.ajax({
  dataType: "json",
  url: url,
  data: {idFacebook: idFacebook},
  success: function(result) {
    console.log(result);

  },
  error: function (xhr, ajaxOptions, thrownError) {
    alert(xhr.status);
    alert(thrownError);
  }
});