前端ajax提交number類型的值-1
:
$.ajax({
url : theUrl,
data : {
data: {s: -1} // s是整數(shù)值-1
},
type: 'post',
success: function(data) {
console.log(data);
}
}
php端獲取到的卻是string類型的"-1"
:文章來源:http://www.zghlxwxcb.cn/news/detail-801878.html
$data=$_POST['data'];
// {"s":"-1"}
echo json_encode($data);
參考:https://stackoverflow.com/questions/22779402文章來源地址http://www.zghlxwxcb.cn/news/detail-801878.html
到了這里,關(guān)于php踩坑:ajax向php提交整型值,$_POST中獲取到的卻是string類型的值的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!