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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:41:36+00:00 2026-06-12T13:41:36+00:00

I’m learning how to integrate JQuery, AJAX and PHP together. My problem is that

  • 0

I’m learning how to integrate JQuery, AJAX and PHP together.

My problem is that my success function isn’t getting any value from the parameter and just getting a ‘0’. I’m not really sure what I’m doing wrong either, but I have just been following this tutorial JQuery & PHP Tutorial and just copied how he got the value from the PHP code using echoes and a parameter variable r.

I have tried searching for the solution, but I’m not sure if any of the results are relevant to what I am doing. I tried following some of their advice but none seems to work (the promise thing for jQuery)

I hope someone can enlighten me what I am doing wrong as I am eager to learn more PHP and jQuery.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>
    $(function () {
        jQuery("form").submit(function(e) { 
             var input = $("#input").val();
             var url = 'input=' + input;
             $.ajax({
               type: "POST",
               url: "process.php",
               data: url,
               success: function(r) {
                   $("#output").text(function(r) {
                        return r;
                   });
               }
             });
             e.preventDefault();
        });
    });
</script>
<title>Insert title here</title>
</head>
<body>
    <form action="process.php" method="post">
        Inputs:<br />
        <textarea rows="15" cols="60" id="input" name="input">Some text...
        </textarea><br /><br />
        Start:
        <input type="text" id="start" name="start" />
        End:
        <input type="text" id="end" name="end" /><br />
        <input type="submit" id="submit" name="submit" value="Submit">
    </form>
    <p id="output">Output: Some Random Text</p>
</body>
</html>

PHP:

require 'parser.php';
$parser = new Parser();
#header('index.php');
$hash = $parser->parse($_POST['input']);
$keys = array_keys($hash);
foreach($keys as $key) {
    echo "$key ->";
    $dests = $hash[$key];
    foreach($dests as $dest) {
        echo " $dest";
    }
    echo "<br />";
}

?>
  • 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-12T13:41:37+00:00Added an answer on June 12, 2026 at 1:41 pm
    <script>
        $(function () {
            jQuery("form").submit(function(e) { 
                 var input1 = $("#input").val();
                 var url = {'input' :  input1};   // a little change to the data parameter
                 $.ajax({
                   type: "POST",
                   url: "process.php",
                   data: url,
                   success: function(r) {
                    //   $("#output").text(r);  //<--- changed to this
                       $("#output").html(r);  // this is better as you output html
                   }
                 });
                 e.preventDefault();
            });
        });
    </script>
    

    for jquery text(), use the return value from the server directly. If you are outputting html use jquery html() instead

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
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 want to count how many characters a certain string has in PHP, but
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.