[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Ajax toggle status

Posted on 2014-01-24
4
Medium Priority
?
402 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
2 Comments
 
LVL 44

Assisted Solution

by:Rainer Jeschor
Rainer Jeschor earned 1000 total points
ID: 39806201
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 111

Accepted Solution

by:
Ray Paseur earned 1000 total points
ID: 39806241
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

872 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