Log in

View Full Version : ajax+php+mysql question



flash
09-30-2007, 02:16 PM
I've been trying to do this for like 2 weeks someone please help me.
http://flash.tymatik.com/goober/index.php
I am trying that when someone presses the digg button it will add a number through ajax.
I mean my vote.php (http://pastebin.ca/720589) already does it I just want to show $diggs_found for each of the articles again. without refreshing.
I need a JS function to call vote.php?digg=id and when it does show the new value which $diggs_found does that atm.

Rockonmetal
09-30-2007, 02:29 PM
It works for me...

flash
09-30-2007, 02:30 PM
yeah but i want it to work through ajax , without refreshing.
I understand that i need to make vote.php echo something maybe exit('OK:1234'); and then Votes: <span id=article_1234> alertContents function
or replacing the div problem is I dont know how to do it all , calling vote.php and such.
var file = 'vote.php?digg=';
xmlhttp.open('GET', file + id, true);
works for me for calling the vote
<td width="67" height="20"><? echo '<a href="javascript:vote('. $row['a_id']. ')">'; ?><img src="2.jpg" width="67" height="20" border="0" /></a></td>
with document.getElementById or something.

Rockonmetal
09-30-2007, 09:37 PM
As a user, it doesn't refresh for me, it just doesn't refresh the page...
Sorry man but to me there isn't any refresh so, either you just changed it or your just seeing stuff...

flash
09-30-2007, 09:54 PM
man it refreshesssses:( maybe too quick for a human eye to see or maybe your connection is urber fast but it does:(
I see it here clearly.
You are right though sometimes it does it so quick that I was suprised too myself , but it does refresh.

insanemonkey
10-01-2007, 03:45 AM
yeh it does refresh... try this..

for your refresh button do not...
make it link to your index page..
in the <a href="index.php"> to <a href="javascript:location.reload(true);">Refresh Page</a>

its better...

and in ajax.. make sure all your linked files are correct like..
add these in front of your urls so it locates it properly..
../folder/ajax/diggit.php
something like that in your urlls.. its what i use..

try that

flash
10-01-2007, 09:17 AM
thank you for the refresh button that works great
the part of my ajax I got from here
http://www.somecoders.com/2006/05/make-an-ajax-poll/
which is not designed for what im trying to do .
I need to know what to change here inorder to make it work
document.getElementById('option' + id).innerHTML = content;
javascript:vote(3) for example when i click vote works but I want it to show the new diggs without refreshing.

flash
10-01-2007, 10:30 AM
I've found this
http://209.85.135.104/search?q=cache:fjJuFyNLfFgJ:360pwners.com/digg/button/+diggit+ajax&hl=iw&ct=clnk&cd=1&gl=il
Question is what would the sendy.js would look like for this to work , I imagine it needs to have a var that would call the diggit.php file.
please help.