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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:44:47+00:00 2026-06-11T03:44:47+00:00

Okey so I got a really wierd problem that I can’t understand. i got

  • 0

Okey so I got a really wierd problem that I can’t understand. i got this piece of jquery code:

HTML CODE

<form>
  <input type="text" value="Search for a product" id="name" size="50">
  <input type="submit" id="submit" value="Search">
</form>

JAVASCRIPT CODE

$("#loader").hide();
$(document).ready(function() {      
  $('#submit').live('click', function(event){
  $("#loader").ajaxStart(function(){
    $(this).show();
  });
  $("#loader").ajaxStop(function(){
    $(this).hide();
  });
  $('.product').remove();
  var query = $("#name").val(); 
  var searchQuery = query.replace(/ /g,"+");     
  $.get("APIsearch.php", {keyword: searchQuery}, function(data){
    $("#content").html(data);
  });  
}); 
});

btw the #loader is just a loading gif that’s shown during the ajax call.

Its simple enough, when I click the button with id “submit” it sends a string from a text field with the id “name” and puts a + where there are spaces between the words and then sends the string to the page APIsearch.php where I get some stuff back that’s then loaded in to the “contetn” div. Now the problem is that when I add the “form” element around the “input” fields my ajaxt wont return anything and I need to have a form around since I want to start using .submit instead so I can use the enter button as a choise to submit the text. why does it only work when I remove the “form” elements like this?

<input type="text" value="Search for a product" id="name" size="50">
<input type="submit" id="submit" value="Search">
  • 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-11T03:44:49+00:00Added an answer on June 11, 2026 at 3:44 am

    When you submit a form, the whole page gets submitted and on the server, you will need to responsed back in html format. You will not be able to just update the div as you have mentioned.

    However, the form element that you have shown does not have “action” specified. This indicates that you want to get the information from the server using Ajax. For Ajax response, you can program the ‘enter’ key to work:

    $("#name").keyup(function(event){
        if(event.keyCode == 13){
            $("#submit").click();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okey, here it goes. I have a block of code that repeats it self
Okey, this is my problem. I have one service class where Ive managed to
Okey, so this is my problem. I want to use mod_rewrite to make nice
Okey so, im kind of new to JBoss. My problem is that i dont
Okey this is really strange. I have this script which basically downloads bunch of
Okey dokey, I have a jQuery function that checks the height of 2 divs
Okey, so this is my problem. I have a page structure saved into a
I'm using JQuery UI Dialog. In this form, I validate something.I call this function;
I've got the following column names that I need to order by the date
I have 2 fields that can be use in row area. One of them

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.