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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:55:17+00:00 2026-05-13T07:55:17+00:00

I’m trying to fire an event on spacebar press if an url is found

  • 0

I’m trying to fire an event on spacebar press if an url is found in the last word typed and kill that event if there is a result so if the user keeps typing… the function doesn’t keep on sending requests to the server. I’m tired and hope this makes sense… Basically I’m trying to accomplish what facebook has when you submit a post and enter an url beginning with http://. I’ve got it working 100% perfect… you can type and type and when an url is entered beginning with http:// it pings the server, grabs meta data, images from page, etc. But when the user keeps typing, the function seems to go for a loop and freezes because it’s still trying to find an url?

Heres the code anyhow below:

$(document).keypress(function(e){
$('#example').keyup(function() { 
if(e.which == 32) {
var body = $('#example').attr('value');
var body = encodeURIComponent(body);
$.ajax({
type: "GET",
url: "get_url.php",
data: "entry="+body,
cache: false,
success: function(html) {
$("#new_url").html(html);
}
});
return false;
}
});
});

I know it’s messy… still learning jQuery!

Thanks for all the help! I would like to scan the textarea input as the user types for an url starting with http://, www, or http:// w w w. using jquery, when found trigger the ajax request and stop the function from looking any further for urls… but am currently using regex in php to find url, fetch data, and return it…

  • 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-13T07:55:18+00:00Added an answer on May 13, 2026 at 7:55 am

    Try this:

    $(document).ready(function() {    
        $('#example').keyup(function(e) {                   
            if(e.which == 32) {                     
                var body = $('#example').attr('value');                     
                body = encodeURIComponent(body);                        
                $.ajax({
                    type: "GET",
                    url: "get_url.php",
                    data: "entry="+body,
                    cache: false,
                    success: function(html) {
                        $("#new_url").html(html);
                    }
                });
                return false;
            }
        });
    });         
    

    It doesn’t trigger on EVERY key pressed on the entire body.
    Furthermore I declare the body var only once.

    Tested it locally, doesn’t lock up anymore, but don’t get any usefull response as get_url.php doesn’t seem to return anything.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am trying to render a haml file in a javascript response like so:

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.