Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Ajax toggle status

Posted on 2014-01-24
4
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

636 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