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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:53:44+00:00 2026-06-17T13:53:44+00:00

So I have a test input and a submit button. I want to send

  • 0

So I have a test input and a submit button. I want to send the data via jQuery and retrieve the result from the post request and then display the value that the post request returns, without refreshing the page.

Here is my html:

<div id="middle">
    <form id="searchForm" action="/">
        <input placeholder="E.g. http://www.google.co.nz" id="url" type="text" name="forward_to"/>
        <input id="button" type="submit" name="shorten" value="Go"/>
    </form>

    <div id="result"></div>

</div>

Here is my php

if($query) {
    print("<div id='content'>http://www.website.co.nz/u/$short</div>");
} else {
    print("<div id='content'>Error</div>");
}

Is there anyway to do this?

  • 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-17T13:53:45+00:00Added an answer on June 17, 2026 at 1:53 pm
    $(document).ready(function(){
        $('#button').click(function(e){
            e.preventDefault();
            $.ajax({
                type: 'post',
                url: '/',
                data: { query:  $('#url').val() },
                success: function(data) {
                   $("#result").html(data);
                },
                error: function() {
                  $("#result").html("Some error occurred.");
                }
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this: $(document).ready(function() { $(input[type=button]).click(function () { $(#test).html(W3Schools); alert(Would submit: + $(this).siblings(input[type=text]).val()); $.ajax({
I have a form that I pre-populate with test data though jQuery. $('INPUT[name=subscription.FirstName]').val('Jef'); but
I have a form like <input type=text name=test value=> <input type=submit name=submit value=Send> When
I have the below form that i want to remove the submit button from
I have a button on a file test.php <?php $url=http://.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?> <input type=button name=btn
i have 1 php page containing 2 forms and 1 submit button.i want to
i have a got a form, on clicking the submit button: I want to
I want to disable my submit button until all the fields have values.. how
I have a simple form and i want the submit button not to work
I have the following code: main = do putStr Test input : content <-

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.