0

You can see my fiddle of what i'm doing here: fiddle

In vote_up.php I insert the vote into MySQL and replaces the link with 2 messages:

"successful" or "error"

But the problem now is, I don't need to change the link, I must update the 2 boxes showing a new question without reloading the page.

This is before I vote: Before voting up

And after I vote:After voting up

What i need when they click up(Aceptar) is it changes the question instead of showing that I voted. Thanks.

1
  • Ok, i found something interesting: --$("#mod-question").html('new question'); -- Now what i must find is how to do the php and sql selects for the new question. Commented Sep 5, 2011 at 9:17

2 Answers 2

1

You need a backend that gives the information back in a format (like JSON or XML) and then parse it into the page. When they click the vote link there happens a ajax request to vote. And the response of this ajax request is your new question.

Then you parse the request, replace your old question with the new one. And replace your ajax request URL with the new ID of the new question. (so you can vote always again)

Sign up to request clarification or add additional context in comments.

3 Comments

So i must write all the page $("#mod-question").html('here'); with each div replaced. Or ""And the response of this ajax request is your new question."" do you mean all the question and html code must be there? I'm sorry, no jquery developer :( Totally lost. Thanks
I'm no jQuery dev either :) But what I would do is to give each element that needs to be replaced an ID or class and replace the contents of each element. (div with the question you just replace the text, the anchor to vote just replace the href etc. etc.) This is a good practice, because if you want to change your layout, you just need to assign the classes (or ID's) to the new elements and your script still works.
Thanks you with your info. I was null at jquery. I created the xml(dynamic). I parsed the xml and replaced the old divs and hrefs with. But got errors and errors. I Answered my question.
0

My problem resolved in other post:

$(document).ready(function()
{

$(document).delegate('.vote, .vote1', 'click', function()
    {
...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.