Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,134 members, 7,818,420 topics. Date: Sunday, 05 May 2024 at 03:00 PM

TUTORIAL: Learn How To Create A Mention With Jquery, AJAX And PHP. - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / TUTORIAL: Learn How To Create A Mention With Jquery, AJAX And PHP. (1024 Views)

Simple Drop Down Menu With Jquery And CSS / How Do I Get A User Serial Number With Jquery Or Javascript?? / Submit Checkbox Values In Form With Jquery (2) (3) (4)

(1) (Reply)

TUTORIAL: Learn How To Create A Mention With Jquery, AJAX And PHP. by frontdevguy: 12:27am On Sep 07, 2017
The Algorithm.

Step 1:

Prevent user from submitting the form when the submit button is clicked. Using event.preventDefault();

Step 2:

Get the user’s text/comment and save in a variable.

Step 3:

Search for all the positions of the mention symbol e.g @ in the user’s text/comment.

Step 4:

Using the positions of the @ gotten in step 3, we get the string attached to the symbol also. e.g @learnMention. The attached string is ---> learnMention <--- .

Step 5:

All the attached string is being push into an array.

Step 6:

Make an AJAX request with METHOD:”POST” to our server-scripting language in this case PHP with the user’s Name, User’s Text/Comment
And the array(Step 5) being passed.

Step 7:

The array is being looped over with each time making a request to the database to check if the string exist as a Username or an Organization Name.

Step 8:

If the string exist a Username or an Organization Name, the string is replaced we a link to the User/Organization Account in the User’s Text/Comment but if it doesn’t exist it remains unchanged.

Step 9:

The replaced comment gets sent into our database and return back to our AJAX which made the request at first.

Step 10:

On success our AJAX calls another AJAX to make a request into our database to fetch the comments and display them to the user.



.......

Index.php


Feel to drop your suggestion on how to make this code better or any other suggestion of yours.


https://github.com/frontdevguy/Mention


instantaneous mention/message notification system (similar to that of Facebook) drooping soon!!!

1 Like 1 Share

(1) (Reply)

True Or False? / Code For PHP Assignment / Ethical Hacking 2017

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 6
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.