weixin_33737774 2015-03-30 16:52 采纳率: 0%
浏览 44

实现Ajax / Jquery

OK, I am going to preface this with the warning that my code skills are really rudimentary--I've cobbled together what I can, but my lack of experience with Javascript is keeping me from implementing this final thing. I have my page set up: http://excitable.media/reddit.php

It is almost doing what I want. The arrows are changing on click with the CSS. The Big number is being called from an SQL Database, in a table named votes that has only one column--count. What I want to happen now is that when someone clicks the up arrow, the count entry is increased by one and the vote count on the page is updated. I know I need AJAX/JQuery to do this, but once again, even the syntax is difficult for me. Here is the page code right now:

<html>
<head>
<meta charset="utf-8">
<title>Reddit</title>

<link rel="stylesheet" type="text/css" href="css/css/reddit.css">

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="css/js/reddit.js"></script>

</head>
<body>
<h1>reddit</h1>

<div class="container">
<div class="up">
<input id="img-switcher" type="checkbox"></input>
<label for="img-switcher"></label>
</div>
<div class="count" id="vote-value">
<?php
include '../php/config.php';
$con;
$dbhandle;
$selected;
if($vote)
echo $vote[0];
?>
</div>
<div class="essay">
<p>Registering an account with Reddit [paragraph text omitted]</p>
</div>
<div="down">
<input id="img-switcher-2" type="checkbox"></input>
<label for="img-switcher-2"></label>
</div>
</div>

</body>
</html>

Can anyone help me with this rudimentary coding project? I have another php file called 'insert.php' that connects to the database and then says:

$update=mysql_query("UPDATE 'votes' SET 'count'='count'+1)");
if(mysql_query($update)){
    return "success!";
}
else {
    return "failed!";
}

The reddit.js file is totally empty right now, it's where I am expecting to place the code to make this work. It's also worth mentioning that I don't care about the down arrow at all. I don't want it to function. I only want the up arrow to work. I don't care if people click it more than once from the same IP.

  • 写回答

3条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥20 SQL数据查询,子查询
      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver