1
我试图通过datastring传递一个值,但由于某种原因id没有通过。这里的代码:Ajax datastring不通过
<script type="text/javascript">
$(document).ready(function()
{
$(".sourcecountry").change(function()
{
var id=$(this).val();
var dataString = 'id='+ id;
console.log(id);
$.ajax
({
type: "POST",
url: "get_seaports.php",
data: dataString,
cache: false,
success: function(html)
{
$(".selcab").html(html);
}
});
});
});
</script>
控制台是表示ID被加载并get_seaports.php正在更新.selcab,但$ ID = $ _ POST [ 'ID'];在那个文件中得到一个空值。
我有其他的ajax使用相同类型的代码和它的工作。
代码有什么问题?
对不起,请您详细说明一下吗?我需要在代码中更改什么? –
用我的行替换你的以var dataString开头的行。 – arctelix
谢谢!它工作 –