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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:02:54+00:00 2026-06-09T12:02:54+00:00

I wish to serialize some session content for an Ajax request. Something similar to

  • 0

I wish to serialize some session content for an Ajax request. Something similar to this:

var data = $.session("data").serialize();

It is for a standard jQuery ajax function like this:

$.ajax({
   type: "POST",
   url: "script.php",
   data: data,
   success: function() {
     ...
   }
});

The serialize() only operates on form elements, so I am looking for something similar. Something that handles an array in a form representing a SESSION data array.

Does that exist or do I have to use a foreach loop to serialize the session content in a POST-friendly string manually?

  • 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-09T12:02:55+00:00Added an answer on June 9, 2026 at 12:02 pm

    The main real reason to use the serialize function on data like that is when it originates from several sources – such as a form element containing many input fields. One serialize command on the form will return all the data.

    If you already have some JavaSctipt variables holding your “session” data, you can simply send them as an object through the AJAX call – there is no need to serialize the data if you already have all of it in one variable.

    If you are wanting to pass some server session variables then you might want to consider the following approach –
    You can save your session variable data and encode it to a json object using json_encode(). After that you can pass it to your JavaScript simply by echoing it out into a variable –

    var sess_data = '<?php echo json_encode($_SESSION); ?>' ;
    

    Then you can just pass the variable with your AJAX call – no need to serialize the data.

    $.ajax({
       type: "POST",
       url: "script.php",
       data: sess_data,
       success: function() {
         ...
       }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wish HTML could do something semantically equivalent to this; <dl class=main-list> <definitionitem> <dt>Some
I have a form I wish to submit via ajax usind the jQuery $.post
This is my first time using AJAX with ASP.NET so please allow m some
I wish to request data from a web service endpoint( say http://www.example.com ) using
I have some objects that I wish to cache on disk. I use serialize()
I have a set of classes I wish to serialize the data from. There
How can I turn off session persistence for geronimo? Is this something I should
I wish to save some semantic information about data in a table. How can
Possible Duplicate: How to serialize an IList<T>? I wish to serialize an class (let's
I wish to do this using only XAML - How to add an additional

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.