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

  • Home
  • SEARCH
  • 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 4536616
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:33:37+00:00 2026-05-21T14:33:37+00:00

I would like to have the following: User submits a form by a click

  • 0

I would like to have the following:

User submits a form by a click (index.php), the form input is processed by an external PHP file (search.php) and results are posted on the original page (index.php) in a div.

I have already got together most of the code. It submits a form on a click and sends it to a PHP script.

What I would need now is that the result from the PHP script are given back to the original page (index.php).

Here is my code so far:

function submit() {
    $(function() {
        var id = "id";
        var dataString = 'id=' + id;
        $.ajax({
            type: "POST",
            url: "inc/search.php",
            data: dataString,
            success: function() {
                goToByScroll("result");
                $('#result').html("<br><br><br><br><br><br><br><br><br><br><
                                   div class='center'><img src='img/loader.gif' /></div>").hide().fadeIn(2500, function() {
                $('#result').html("Finished");
                });
            }
        });
        return false;
    });
}

My PHP file (for testing) is:

<?php function safe($value)
{
    htmlentities($value, ENT_QUOTES, 'utf-8');
    return $value;
}
if (isset($_POST['id'])) {
    $id = safe($_POST['id']);
    echo ($id);
}
elseif (!isset($_POST['id'])) {
    header('Location: error?id=notfound');
} ?>

I would like to have results from search.php (in this case “id”) posted into #result, but I can’t figure out how :S

  • 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-21T14:33:38+00:00Added an answer on May 21, 2026 at 2:33 pm

    I think you’ve got almost everything. The callback function you have under success needs an argument which stands for the results from search.php

         success: function(res) {
                 goToByScroll("result");
                 $('#result').html("<br><br><br><br><br><br><br><br><br><br><div class='center'><img src='img/loader.gif' /></div>").hide().fadeIn(2500, function() {
                     $('#result').html(res + "<br /><br /> Finished");
                 });
             } 
    

    res is everything outputted be search.php. Echo, stuff outside of php tags, etc Anything you’d see if you loaded search.php itself.

    I don’t know if you wanted ‘Finished’ to still be there. Take it out if you dont.

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

Sidebar

Related Questions

I have the following LINQ that I would like to also order by file
I have the following form: <form:form method=POST action=signin.dlp commandName=user > <form:input path=useremail id=useremail /><FONT
I would like to make my own user-mode NAT application. I have the folowing
I would like to have the following kind of HTML: <header></header> <div id='main'></div> <footer></footer>
I would like to have the following syntax: python utility.py file1 FILE1 file2 FILE2
I have following line code in my view: <td> Model.some_instance_method(args) </td> I would like
i have the following problem: i would like to create a footer. that footer
I have the following collection which i would like to bind to a combobox:
Say I have the following: [Test] // would like to parameterize the parameters in
I have the following 2 arrays and would like to combine them. I'm more

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.