gpt4 book ai didi

php - 如何获取ajax值并存储在PHP变量中?

转载 作者:行者123 更新时间:2023-11-29 17:56:44 24 4
gpt4 key购买 nike

custom.js 文件:

$(document).ready(function() {
$("#company_name").keyup(function() {
$.ajax({
type: "POST",
url: "http://localhost/capms_v2/ca_autocomplete/getcompanyName",
data: {
keyword: $("#company_name").val()
},
dataType: "json",
success: function(data) {
//alert(data);
if (data.length > 0) {
$('#DropdownCompany').empty();
$('#company_name').attr("data-toggle", "dropdown");
$('#DropdownCompany').dropdown('toggle');

} else if (data.length == 0) {
$('#company_name').attr("data-toggle", "");
}
$.each(data, function(key, value) {
if (data.length >= 0)
$('#DropdownCompany').append('<li role="displayCountries" ><a role="menuitem DropdownCompany" id=' + value['company_id'] + ' Address1=' + value['company_address1'] + ' Address2=' + value['company_address2'] + ' city=' + value['company_city'] + ' state=' + value['company_state'] + ' pincode=' + value['company_zip'] + ' class="dropdownlivalue">' +
value['company_name'] + '</a></li>');
});
}
});
});
$('ul.txtcountry').on('click', 'li a', function() {
$('#company_name').val($(this).text());
$('#company_id').val($(this).attr("id"));
// $('#company_address1').val($(this).text());

$('#tableCityID').html($(this).attr("id"));
$('#tableCityName').html($(this).text());
$('#Address1').html($(this).attr("Address1"));
$('#Address2').html($(this).attr("Address2"));
$('#city').html($(this).attr("city"));
$('#state').html($(this).attr("state"));
$('#pincode').html($(this).attr("pincode"));
});
});

我在span id="tableCityID"中获取id,但是如果我存储该值并将该值传递给mysql,它就不会获取该值

$com = '<span id="tableCityID">'; 

如果我回显选择查询

echo $sql="select * from ca_job WHERE job_status!='Closed' AND job_customer_name = '".$com."'";

我得到的结果是未完成的单个代码

select * from ca_job WHERE job_status!='Closed' AND job_customer_name = '15

如果有人遇到这个问题,请帮助我。提前致谢。

最佳答案

只需使用 </span>

像这样

$com = '<span id="tableCityID"></span>';

关于php - 如何获取ajax值并存储在PHP变量中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48745781/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com