jquery的ajax查询数据库,使用ajax从数据库获取数据jquery

我有一些问题通过在我的jQuery脚本中使用ajax从数据库获取值。

的index.php:使用ajax从数据库获取数据jquery

arrow_left.png

的script.js

$(document).ready(function() {

$(".arrow").click(function() {

$.ajax({

type: "GET",

url: "../db/db_getvalues.php", // This is the correct path, but do jquery recognize "../db/" etc?

dataType: "text",

success: function (response) { // Here is where i'm lost, what do i need to write to update my innerHTML with the returned value from the db_getvalues.php-file?

$(".text-box").html(response);

}

});

});

});

db_getvalues.php //此文件的工作,我已经直接从HTML文件

function getdbvalues() {

$query = 'SELECT * FROM mydb WHERE Id = 1';

$fetch = mysql_query($query) or die ('Could not find tablerow');

$row = mysql_fetch_assoc($fetch);

$textString = $row['Text'];

return $textString;

}

?>

+0

你目前得到的输出是什么? –

2014-11-22 15:38:42

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值