Javascript PHP$\u获取值未从jQueryAjax调用中获取-PHP包含问题?
我的PHP文件viewFrontPage.PHP有一个case语句,根据匹配的case包含不同的.PHP文件 我有单选按钮,用于选择我要在URL中拉入的数据: })) 在包含的文件viewByPrices.php中,我有以下内容:Javascript PHP$\u获取值未从jQueryAjax调用中获取-PHP包含问题?,javascript,php,jquery,mysql,ajax,Javascript,Php,Jquery,Mysql,Ajax,我的PHP文件viewFrontPage.PHP有一个case语句,根据匹配的case包含不同的.PHP文件 我有单选按钮,用于选择我要在URL中拉入的数据: })) 在包含的文件viewByPrices.php中,我有以下内容: <?php $price = isset( $_GET['price'] ) ? $_GET['price'] : "not working"; ?> 我在Firefox web控制台中看到HTTP GET遇到了ok: 但是美元的价格并没
<?php
$price = isset( $_GET['price'] ) ? $_GET['price'] : "not working";
?>
我在Firefox web控制台中看到HTTP GET遇到了ok:
但是美元的价格并没有拉进来,因为它拉进来的是“不起作用”,有什么想法吗?这是包含的问题吗?这是因为我调用以处理数据的php文件与我试图用于回发响应的文件相同吗?
if($(this).prop(“checked”,true))
应该是if($(this).prop(“checked”)
。两个参数用于设置属性,而不是测试属性。它实际上应该是this。选中了。此外,就单选按钮上的更改事件而言,它不是只在选中的按钮上触发,而不是取消选中的按钮上触发吗?所以if有点不必要$(“.shopping\u main\u section”).innerHTML=this.responseText代码>也是一个问题。使用.html(this.responseText)
<代码>innerHTML
未在jQuery对象上公开
$(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);
}
})
}
})
<?php
$price = isset( $_GET['price'] ) ? $_GET['price'] : "not working";
?>