My PHP file viewFrontPage.php has a case statement which includes different .php files based on the the matching case.
I have radio buttons which select the data I want to pull in at the URL: http://localhost/xyz/views/viewFrontPage.php?view=viewPrices
<?php
echo "<input type=\"radio\" id=\"0_to_1000\" name=\"prices_radio\" value=\"0_to_1000\">$0 - $1000<br>";
echo "<input type=\"radio\" id=\"1000_to_2000\" name=\"prices_radio\" value=\"1000_to_2000\">$1000 - $2000<br>";
echo "<input type=\"radio\" id=\"2000_to_5000\" name=\"prices_radio\" value=\"2000_to_5000\">$2000 - $5000<br>";
echo "<input type=\"radio\" id=\"5000_to_10000\" name=\"prices_radio\" value=\"5000_to_10000\">$5000 - $10000<br>";
?>
I have my jQuery AJAX call in a javascript file, and the URL for the AJAX call points to one of the included files in viewFrontPage.php that's included based on the matching case statement as described above. The file is viewByPrices.php
$(document).ready(function () {
$("input[name=prices_radio]:radio").change(function () {
if ($(this).prop("checked", true)) {
//parameters
const value = $(this).val();
$.ajax({
type: 'get',
url: 'viewByPrices.php',
data: {
price: value
},
success: function() {
$(".shopping_main_section").innerHTML = this.responseText;
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
})
}
})
});
In the included file viewByPrices.php I have the following:
<?php
$price = isset( $_GET['price'] ) ? $_GET['price'] : "not working";
?>
I see in the Firefox web console that the HTTP GET is coming across ok:
http://localhost/xyz/views/viewByPrices.php?price=0_to_1000
But the $price value is not pulling in as it's pulling in "not working", any ideas? Is this a problem with the includes? Is this because the php file I'm calling to process the data is the same one I'm trying to use to post the response back?