Solved

Ajax toggle status

Posted on 2014-01-24
4
371 Views
Last Modified: 2014-06-01
I've a page bookmark system in my site using the old coding style. Means that a user clicks on the bookmark button and the database updates with a page refresh. When the user is redirecting back instead of bookmark he is seeing the remove bookmark link. So far so good. At least works.

Now I want to have this feature using Ajax (no page refresh). When the user clicks the Bookmark link an Ajax request to be send to database and the link to change to "Remove bookmark". Clicking it new database update, new bookmark link update and so on.

How I can do it?
0
Comment
Question by:NickTERiS
4 Comments
 
LVL 44

Assisted Solution

by:Rainer Jeschor
Rainer Jeschor earned 250 total points
Comment Utility
Hi,

just some sort of pseudo code.
You would want to use the jQuery.post() function, passing the data form values.
In the success callback you will have to verify the response if the database update was successful and if yes run additional jQuery functions to change the link text / button ...

Please have a basic look on the documentation page - especially the last sample:
http://api.jquery.com/jquery.post/

HTH
Rainer
0
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 250 total points
Comment Utility
Here is an EE article that shows all of the essential moving parts of jQuery / AJAX.  Please read it over and post back if you still have any questions.
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now