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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:55:11+00:00 2026-06-13T22:55:11+00:00

So, I have a form with one input text field(search_term) and a submit button.

  • 0

So, I have a form with one input text field(search_term) and a submit button.

What I’m trying to do is type in a keyword into the input text field, press Submit, the keyword gets sent to a php script that will json_encode it and send it back to the form page where an alert box should appear and show the keyword.

Instead I keep getting null shown in the alert box after pressing the submit.

PHP script works fine if I actually type it out in the url with keyword passed too:

localhost/filter.php?search_term=hey

JavaScript to submit the form and get the value back asynchroniously(without reloading the page):

$('#filter_form').on('submit', function(e){
                    var filtered_data = null;

                    e.preventDefault();


                    $.ajax({
                        type: 'GET',
                        dataType: 'json',
                        url: 'filter.php',
                        async: false,
                        success: function(json)
                        {
                            filtered_data = json;
                        }
                    });

                    alert(filtered_data);
                });

filter.php:

$search_term = $_GET['search_term'];
    echo json_encode($search_term);
  • 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-13T22:55:12+00:00Added an answer on June 13, 2026 at 10:55 pm

    You need to POST the value of the input to the processing page.

    $('#filter_form').on('submit', function(e) {
        e.preventDefault();
        $inputValue = $('#search_term').val(); //if the id of the input is "search_term"
        $.ajax({
            type: 'POST',
            data: {
                'inputValue': $inputValue
            },
            url: 'filter.php',
            success: function(json) {
                alert(json);
            }
        });
    });​
    

    filter.php should be changed to:

    $search_term = $_POST['inputValue'];
    echo json_encode($search_term);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this field in one form : <input type=text name=promocode id=promoCode value= style=width:24%
I have got a simple HTMl form with one field as follows: <input type=text
I have a form with two input fields, one text and one send button.
I have three input text boxes in my form. First one is teacher, second
I have one form with several text fields and one button. When i enter
I'm trying to have two functions checking each form input, one for onchange() and
I have a very simple GET form with one text field: <form action=blah method=get
I have a simple form with one input field. It works fine when I
<form id=youtube-form method=post action=> <label for=searchField id=label-youtube-id>YouTube ID:</label> <input type=text id=searchField name=videoid class=search-field />
I have a form in CakePHP that has two live-search text input. Each one

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.