Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9154273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:24:08+00:00 2026-06-17T12:24:08+00:00

I am trying to make a name tagger in jquery + php. I have

  • 0

I am trying to make a name tagger in jquery + php. I have done the PHP part and jquery code is 99% done, but my problem is passing the string to search for after the ‘@’ sign. I currently use a div with contentEditable set to true. From what I see in console log the name variable is indeed @+search string, but the list div will not be populated, I tried running the script manually just to debug and it works, including setting the name variable to one specific letter and it populates the list div. Any tips and suggestions appreciated my code below:

$("#chat-message").bind("keyup", function (event) {
    //auto name complete
    var search = $(this).text();
    var searchbox = search.split(search.indexOf('@') + 1);
    var checker = search.substr(search.length - 1); //Checks last charcter inserted if its '@'
    var name = search.match(/@(\w+)/ig);
    console.log(name);
    var dataString = 'searchword=' + name + '&search=yes';
    if (name == '' || checker == " ") {
        $("#display-search").hide();
    } else if (checker === "@") {
        $.ajax({
            type: "POST",
            url: "searchy.php",
            data: dataString,
            cache: false,
            success: function (html) {
                $("#display-search").html(html).show();
            }
        });
    }
    return false;
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:24:08+00:00Added an answer on June 17, 2026 at 12:24 pm

    Try changing your ajax call to this:

    $.ajax({
        "type": "POST",
        "url": "searchy.php",
        "data": {
            "searchword": name,
            "search": "yes"
        },
        "cache": false,
        "error": function (jqXHR, textStatus, errorThrown) {
            // log error to browser console
            console.log(textStatus + ': ' + errorThrown);
        },
        "success": function (data, textStatus, jqXHR) {
            console.log(data);
            $("#display-search").html(data).show();
        }
    });
    

    What, if anything, do you see in the console?

    UPDATE

    If you’re not seeing anything, AJAX isn’t getting called. Try a console log to make sure checker actually equals '@'.

    UPDATE:

    The fundamental problem you’re going to have with your logic is that the AJAX function will only be called when checker === '@'. As checker is the last character that the user typed, name will never exist when checker === '@'.

    I would suggest the following logic instead:

    $(document).ready(function () {
        'use strict';
        var ajaxIsActivelyPosting = false, // flag to prevent a post on every keyup
            searchForTerm = function searchForTerm(e) {
                //auto name complete
                var search = $(this).text(), //get the text
                    matches = search.match(/@(\w+)\s?/ig), // get any matches
                    name = matches ? matches : ''; // if there are matches, set the name
                if (name && !ajaxIsActivelyPosting) { // if there's a match, name will be truthy
                    $.ajax({
                        "type": "POST",
                        "url": "searchy.php",
                        "data": {
                            "searchword": name,
                            "search": "yes"
                        },
                        "cache": false,
                        "beforeSend": function (jqXHR, settings) {
                            ajaxIsActivelyPosting = true; //set the flag
                        },
                        "complete": function (jqXHR, textStatus) {
                            ajaxIsActivelyPosting = false; //clear the flag
                        },
                        "error": function (jqXHR, textStatus, errorThrown) {
                            // log error to browser console, always helpful to have
                            console.log(textStatus + ': ' + errorThrown);
                        },
                        "success": function (data, textStatus, jqXHR) {
                            console.log(data); //see raw result in browser console
                            $("#display-search").html(data).show();
                        }
                    });
                } else {
                    $('#display-search').hide();
                }
                return false;
            };
        $('#chat-message').bind('keyup', searchForTerm);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a menu in this style with the same code: http://www.jeremymartin.name/examples/kwicks.php?example=1
I'm having a problem when trying to make vim expand the file name under
I was trying to make the simple server code work: /* NAME: udpServer0 SYNOPSIS:
I'm trying to make a name field filter with jQuery and I tried so
I have been trying to make something like Facebook @tagged Friend name add in
I'm trying make it work. And I have a lot of errors, but this
im trying to make a small name summary function depending on the size of
I'm trying to make a dynamic regex that matches a person's name. It works
I trying to make a schema for the following xml. <root> <allow_any_name id=string> <required_tag_1>string</required_tag_1>
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.