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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:51:18+00:00 2026-05-30T17:51:18+00:00

I am struggling with the post() method. I’ve been reading several posts on here

  • 0

I am struggling with the post() method.

I’ve been reading several posts on here and the jquery forums, and just trying to get a simple piece of code working is proving difficult. My ultimate goal is to pass a div #exportData and all it’s children to test.php.

I started with:

$.post("ajax/test.php", $("body").html());

To my mind this should return the entire contents of the current page to test.php (unless test.php requires a holding div or element to receive the content). Currently it only returns the blank page.

I then tried looking at the parameters for post() if I need to manipulate these:

$.ajax({
        type: 'POST',
        url: ajax/test.php,
        data: data,
        success: success,
        dataType: dataType
    });

Also declared a variable:

var data = { 
        html: #exportData
    };

That bit failed of course. I don’t know how to define the data in the parameters, or if this is the right place to do it.

Although I would have thought if:

 $.post("ajax/test.php", $("body").html());

would have worked then presumably I can substitute “body” for any class, id or selector I like.

Also does the submit button need certain parameters to tie it to the post function. At the moment it is purely:

<input type="submit" id="submit" value="send" name="submit">

Sorry this is such a basic question.

  • 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-30T17:51:19+00:00Added an answer on May 30, 2026 at 5:51 pm

    You could do

    var html = $("body").html();
    var data = { 
            html: html
        };
    $.post("ajax/test.php", data);
    

    as the second parameter of $.post() is an object wich contains the data you want to send to the server.

    To send the data you could do:

    <input type="submit" id="submit" value="send" name="submit">
    

    js

    $('input#submit').click(function(e){
      //prevent submitting the form (if there is a form)
      e.preventDefault();
        var html = $("body").html();
        var data = { 
                html: html
            };
        $.post("ajax/test.php", data);
    });
    

    server side you receive the data

     $html = $_POST['html']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been struggling to get my mind around classes. Even after reading several websites
im struggling with syntax here: hopefully this question is v simple, im just miising
I've looked through some posts around here, but am still struggling to get my
I have been struggling to get my jquery call to a webmethod to work.
I am really struggling trying to get something very simple achieved. Essentially, I have
Been struggling with this simple selector problem a couple of hours now and must
Been struggling with replacing a backslash by another symbol such as '.-.' just to
I'm struggling to find the right terminology here, but if you have jQuery object...
I have a simple form using a POST method, consisting of a text box
I'm struggling with something that I am sure has a very simple method, but

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.