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 3439614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:19:54+00:00 2026-05-18T08:19:54+00:00

I have a website that lets users comment on books and articles, and the

  • 0

I have a website that lets users comment on books and articles, and the main form has a search input for finding a relevant book or article (sources). I use jQuery to dynamically load new sources from an outside site based on the search terms entered, and then also return sources in a list using AJAX. I have two problems:

  1. Right now, after the user enters four characters, the jQuery runs with every new keypress event. What’s a better way to wait for the user to stop typing, and then only run the jQuery event then?
  2. In Firefox, the list is not styled though the CSS for the list is contained in the main CSS sheet already associated with the page. (This works just fine in Chrome and Safari.)

I use CodeIgniter, but most of the example code should be accessible regardless of familiarity with CI. As said above, all CSS right now is in one sheet that is associated with this page.

Here is the basic form html:

<?=form_open('/scrawls/add')?>
<h2>Add a Scrawl</h2>
<div id="scrawl-source-container">
    <p class="form-par">Search for a reference:</p>
    <input type="text" name="scrawl_source_search" id="scrawl-source-search">
    <div id="scrawl-source-suggestions">
        // this is where the list of suggestions is inserted
    </div>
</div>
<input type="hidden" name="scrawl_source_id" value=0 id="scrawl-source-id">
// redacted code here that deals with other fields 
<div id="selected-ref">
    You've selected: <span id="selected-ref-name"></span>
</div>
// redacted code here that deals with other fields
<?=form_submit('scrawl_submit','Post')?>
<?=form_close()?>

Here is the javascript (not my strongsuit):

$(document).ready(function() {

$("input#scrawl-source-search").keypress(function() {
    var length = $(this).val().length;
    // check to see if there are more than four characters in the input field
    if (length > 4) {
        // need to make some sort of loading div here
        // make Ajax request to find matching sources
        $.post("http://mysite.com/refs/refMatch",{ term:$("input#scrawl-source-search").val()}, function(data) {
            if (data=="No output") {
                $("div#scrawl-source-suggestions").show();
                $("div#scrawl-source-suggestions").html("No matches.");
            } else {
                $("div#scrawl-source-suggestions").html(data).hide();
                $("div#scrawl-source-suggestions").slideDown();
            }
          });
    }
});
});

The ‘refMatch” page which is accessed via AJAX checks an external site to see if there are any new additions that need to be made to the database, then outputs matches from the db. Here is the output file:

<?php
if(isset($refs))
{
echo '<ul class="autocomplete-list">';
foreach($refs as $r)
{
    echo '<li class="autocomplete-entry">';
    echo '<span class="source-id" style="display:none">'.$r->ref_id.'</span><span class="source-title">'.$r->ref_title.'</span>';
    if($r->ref_author != '') {
        echo ' by <span class="source-author">'.$r->ref_author.'</span>';
    }
    echo '</li>';
}
echo '</ul>';
} else {
    echo "No output";
}

So, to repeat my questions, why is FF not styling the AJAX output? And what’s a better way to trigger the jQuery AJAX call?

  • 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-05-18T08:19:54+00:00Added an answer on May 18, 2026 at 8:19 am

    I’m not positive what the problem is, but there’s a few curious things about your post. Given that this works in Chrome and Safari, it would seem that your markup/styles are correct though. Can you provide the URL to your site?

    First, are you adding CSS classes to your elements via Javascript? If so, then the styles you add will only affect those elements which are part of the DOM at that point in time, so you might be experiencing a race condition, that actually happens to work in Chrome and Safari, but not Firefox.

    Second, you mention that you’re using jQuery to load data from an outside source (an external web site I presume). This violates the Same Origin Policy and I would expect this to fail in all browsers. This might be the cause of some problems.

    I strongly suggest using Firebug to troubleshoot this. You can use it to inspect HTML and really see what’s going on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that is generated on a customer's website (lets say customer.com)
Here's what I am trying to do. I have a website that lets users
I have a PHP website that lets users add textual information (notes, posts). I
Imagine that we have a website where users can read articles, view photos, watch
So basically I have website that has names of cities that can be checked
I have a website that has highly granulised access and hence requires many web.config
Lets say i have a website mysite.com that will store some sensitive personal data
I have next link that lets users navigate through a list of URL (stored
A website I'm creating lets users have a unique subdomain on the site eg;
How would i go about building a application that lets users see books that

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.