Frontdevguy's Posts
Nairaland Forum › Frontdevguy's Profile › Frontdevguy's Posts
1 (of 1 pages)
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 (of 1 pages)