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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:49:34+00:00 2026-06-07T16:49:34+00:00

EDIT: This works now, code updated. Big thanks to Martin Amps! So I’ve been

  • 0

EDIT: This works now, code updated. Big thanks to Martin Amps!

So I’ve been playing with this for a week now and have hacked together many examples but it hasn’t worked, so I won’t bother posting code since it’s a mess! I’m a jack of all trades, master of none, so I’m not sure where I’m going wrong.

Here’s what I need.


posttest.php

<html>
<head>
<script type="text/javascript" src="./js/jquery-1.7.2.min.js"></script>
</head>
<body>

<form name="processForm" id="processForm" action="process.php" method="POST">
  <input type="text" id="textField" name="textField" />
  <input type="hidden" id="sessionID" name="sessionID" value="myusername" />
<input type="submit" value="Process!" />
</form>

<div id="mydiv"></div>

FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>
FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>FILLER<BR><BR>

<script type="text/javascript">

$('#processForm').submit(function() {
  var text = $('#textField').val();
  var sid  = $('#sessionID').val();

$.ajax({
  url: "process.php",
  type: "POST",
  data: { 'text' : text, 'sessionID' : sid },
  success: function(data) {
    var result = $.parseJSON(data);
    if (result.success) {           
        // Handle your result and update your form accordingly  
        // result.data.someKey  
        $('#mydiv').text('Success! With ' + result.data);

    }
    else {
        // Error handling as applicable
    }
  }
});

    return false;
});

</script>

</body>
</html>

process.php

<?php
$someText=$_POST['text'];

$return = array('success' => false, 
            'data' => $someText
           );

if (isset($_POST['text'], $_POST['sessionID'])) {
    // Do your queries

    $return['success'] = true;
    //$return['data'] = array('someKey' => 'someValue');
    $return['data'] = $someText;
}

echo json_encode($return);
?>

I’ve tried so many examples, and tried making my own from scratch and can’t seem to get it to work! An example of what I’m trying to accomplish would be like when you add a comment on facebook, or a new post.

I hope someone can help out because I feel like I’ve already wasted a week here on this simple task.

Thanks in advance!

  • 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-07T16:49:36+00:00Added an answer on June 7, 2026 at 4:49 pm

    You don’t need to store the session variable in your page, as it’s stored in a cookie already. Assuming you’re using JQuery, here’s a quick sample:

    The markup

    <form id="processForm" action="process.php" method="POST">
       <input type="text" id="textField" name="textField" />
       <input type="hidden" id="sessionID" name="sessionID" value="<?=session_id()?>" />
       <input type="submit" value="Process!" />
    </form>
    

    The Javascript

    $('#processForm').submit(function() {
      var text = $('#textField').val();
      var sid  = $('#sessionID').val();
    
      $.ajax({
        url: "process.php",
        type: "POST",
        data: { 'text' : text, 'sessionID' : sid },
        success: function(data) {
            var result = $.parseJSON(data);
            if (result.success) {           
                // Handle your result and update your form accordingly  
                // result.data.someKey  
            }
            else {
                // Error handling as applicable
            }
        }
       });
    
       return false;
    });
    

    process.php

    <?php
    
    $return = array('success' => false, 
                    'data' => array()
                   );
    
    if (isset($_POST['text'], $_POST['sessionID'])) {
        // Do your queries
    
        $return['success'] = true;
        $return['data'] = array('someKey' => 'someValue');
    }
    
    echo json_encode($return);
    ?>
    

    Note

    You should use absolute url’s and be aware the form/javascript is non obtrusive so you should make it function without ajax too.

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

Sidebar

Related Questions

Edit: I've updated the code below so that it now works, thanks to Rob's
EDIT: I got this working now. I have updated the code: I've looked at
EDIT: This code now works correctly, I only left it in case someone finds
Edit: Updated code. Now works well enough. Foreword. I am an OpenGL newb tasked
EDIT: I realized that this code compiles and works: #include <iostream> template<class Something> class
EDIT: My main code no longer works, should this function work? <script type=text/javascript src=jquery-1.7.2.js></script>
Edit: The bug which prompted this question has now been fixed . In the
This works: Entities.WorkOrderSet.Where(MyCustomMethod); This does not: Entities.WorkOrderSet.Where(o => MyCustomMethod(o)); ( [Edit] Even without new
EDIT: It works but it takes amazingly long to complete. Is this normal, or
I have this jQuery code (function () { function load_page (pagename) { $.ajax({ url:

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.