AJAX/jQuery help needed

a person with ajax/jQuery knowledge, if you have it and have a bit of time leave msg here i'll pm u.


E: OK so the problem is following:

i've a page with images, every image has on the right a box "thumbs up" and when someone will click on it the amount of points will change in database for this image. Evrything works good but i want to add some eye candy because now when i click on the button my browser goes to "u.php" where is the MYSQL ADD script and then back to index by header(Location blabla) which results in a single page reload. I want to load this function in index.php using ajax or jquery without redirecting to u.php but i've no idea how since i can't find in inet how to do it and my jquery/ajax knowledge is about zerooooo. :d

atm i've:

u.php
Quote
mysql_connect("localhost", "root", "haslo")or die("Nie można nawiązać połączenia z bazą");

mysql_select_db("db")or die("Wystąpił błąd podczas wybierania bazy danych");

$id = $_GET['id'];

$pt = $_GET['pt'] + 1;

echo $id;

echo $pt;



$pytanie = "UPDATE obrazki SET punkty=".$pt." WHERE id=".$id."" ;

mysql_query($pytanie);

header("Location: index.php");


and in index.php

Quote
<div class="thumbs"> <li><a href="up.php?id='.$row[0].'&pt='.$row[6].'">
Comments
38
I thought Ajax was a soccerclub in The Netherlands?
and Asynchronous Javascript and XML
Parent
a city... yes..
Parent
city?

its a Football club in the netherlands
Parent
Don't they represent a city?
Parent
I THOUGHT BELGIANS WERE STUPID, OH WAIT
Parent
a city... yes..
Parent
PHOTOSYNTHESIS wannabe
Parent
Photo is a good mate of me .
And he is very dangerous.
Parent
he hates muslims
Parent
You are very dangerous as well

alakbar
Parent
in before "HAHA I TROLLED YOU GUYS IM NOT THAT STUPID HEHE" comment
Parent
why dont you just ask here no-one is going to pm you to help you with something
Read my comment below.
Parent
ask that dutch admin guy, forgot his name
naw its adrenaline or some other dutchie
Parent
jQuery:
Quote$(selector).load(url,data,callback)


http://w3schools.com/jquery/jquery_ajax.asp


or:
http://www.w3schools.com/XML/xml_http.asp

and you should consider to filter your inputs :-D
FEYENOORD>ajax
bahahahah ofc dream on!
Parent
En ik maar denken dat je een Ajacied was :/
Parent
image: 3985-donny-gorter-staand

MET ZN KANKER MATJE
Parent
Quote by u.php
mysql_connect("localhost", "root", "haslo")or die("Nie mo&#380;na nawi&#261;za&#263; po&#322;&#261;czenia z baz&#261;");

mysql_select_db("db")or die("Wyst&#261;pi&#322; b&#322;&#261;d podczas wybierania bazy danych");

$id = $_GET['id'];
$pt = $_GET['pt'] + 1;

$pytanie = "UPDATE obrazki SET punkty=".$pt." WHERE id=".$id."" ;
mysql_query($pytanie);

if(mysql_affected_rows() > 0)
{
echo 'Number of thumbs: '.$pt;
}
else
{
// Fail
}


Quote by index.php
<div id="thumbs_count">Number of thumbs: <?php echo $row[6]; ?></div>

<div class="thumbs"> <li><a href="up.php?id='.$row[0].'&pt='.$row[6].'"></li>
</div>


Quote by jQuery
$(document).ready(function()
{


$(".thumbs li a").click(function() {
var href = $(this).attr('href');
$.get(href, function(data) {
$("#thumbs_count").html(data);
});

});

});


Btw, sanitize all your data before passing it to your query. Also make sure users can't vote twice.
thanks so much :)! I owe you a beer ;ddd

E: btw. i think you didn't read my post carefully. I wrote i want to put the u.php function to index.php and using jquery or ajax induce it in this index.php without reloading the page :P
Parent
I believe its exactly what he gave u, btw its not jquery or ajax, jquery uses ajax in their calls so its still just ajax after all
Parent
y? but isn't jQuery a JS library? :P Ajax is js with xml, as far as i know in jQuery there aren't any xml things
Parent
seems like u misunderstood what xml is (xhtml itself is subset of xml for example, so jQuery selector itself is based on xml), or u have virtually no knowledge about jquery. Just get into jQuery asap, it will help you a lot + its rly easy :)
Parent
ah ok :) i already read some jQuery guides and did some practice and its very easy and usefull :)
Parent
Back to top