gpt4 book ai didi

php - Jquery ajax 从 php mysql 检索文本(数字)

转载 作者:行者123 更新时间:2023-11-30 01:32:51 25 4
gpt4 key购买 nike

我刚刚开始学习 Jquery,我正在尝试使用 Ajax 发布和检索一些数据。我想要推断的数据是一些简单的文本(没有 json),更具体地说是数字。所以我写了这个:

$.ajax({
url : 'finproj.php',
type : 'POST',
data : 'p=' + devidproj,
success : function(resultaat) {

var lengtebalxkx = Math.floor(100*resultaat/<?php echo $number; ?>);
$(".ongelezendonatiesproj").animate({opacity:1}, 300).show();
if(lengtebalxkx > 120)
{
$(".ongelezendonatiesproj").width(120);
}
else
{
if(lengtebalxkx < 1)
{
$(".ongelezendonatiesproj").width(2);
}
else {
$(".ongelezendonatiesproj").width(lengtebalxkx - 10);
}
}
},
});

devidproj 是一个数字,$number 也是一个数字。我尝试添加 dataType : 'text',但这没有用。我试图从中检索数据的 php 文件是:

<?php include('config.php');
$pid = $_REQUEST['p'];
$nieuwgeld = mysql_query('SELECT bedrag, aantal, projectid FROM donaties WHERE projectid="'.$pid.'"');
while($nieuwebed = mysql_fetch_assoc($nieuwgeld)) {
$plusbedrag = $nieuwebed['bedrag'] * $nieuwebed['aantal'];
$nieuwebedragen = $nieuwebedragen + $plusbedrag;
}

if($nieuwebedragen<>0) {echo $nieuwebedragen;} ?>

php 文件工作正常。

我想我在 Jquery 脚本中漏掉了一个逗号或其他东西,但我似乎看不出它出了什么问题:我已经尝试使用alert() 对其进行调试,但没有成功。

最佳答案

使用

data : {p:devidproj},

已安装

  data : 'p=' + devidproj,

关于php - Jquery ajax 从 php mysql 检索文本(数字),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17248304/

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