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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:55:14+00:00 2026-06-06T20:55:14+00:00

/* Helper function to clean up any current data we have stored */ function

  • 0
/* Helper function to clean up any current data we have stored */
function insertSerializedData(ids, type) {
    // Get anything in the current field
    current_data = $('#changes').val();
    if (!current_data) {
        var data = new Array();
        data[type] = ids;
        $('#changes').val(JSON.stringify(data));
    } else {
        var data = JSON.parse($('#changes').val());
        data[type] = ids;
        $('#changes').val(JSON.stringify(data));
    }
    console.log($('#changes').val());
}

I am using the following function to either add data to a current JSON object or create a new JSON object all together to be used in PHP later. Is the stringify() method only for FF? I am using google chrome and I am being given an empty object when using the conosole.log() function…

Also what happens if you try to store two values with the same key? I assume it will overwrite…so I should add a random math number at the end array in order to keep duplicates from showing up?

Thanks 🙂

  • 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-06T20:55:15+00:00Added an answer on June 6, 2026 at 8:55 pm

    These lines may cause problems:

    var data = new Array();
    data[type] = ids;
    

    … because arrays in JavaScript are not quite like arrays in PHP. I suppose what you meant is better expressed by…

    var data = {};
    data[type] = ids;
    

    Besides, current_data seems to be local to this function, therefore it also should be declared as local with var. Don’t see any other problems… except that similar functionality is already implemented in jQuery .data() method.

    UPDATE: here’s jsFiddle to play with. ) From what I’ve tried looks like the array-object mismatch is what actually caused that Chrome behavior.

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

Sidebar

Related Questions

I have a helper function, which basically calls CompareTo on two objects, but does
So basically I have a helper - function records() { $ci = get_instance(); $ci->db->order_by(date,
Using JsViews is it possible to have a converter precede a helper function in
The problem seems very strange. I have a AJAX helper function within a same
I have a helper assembly which includes a function to identify object types: namespace
I have this function: /** * Helper function that adds the values of b
I have a custom function to validate a field, but when i test it
Looking for a nifty helper function/method for grepping through all defined tables, columns, stored
I have a helper function that takes an unsigned char array of a fixed
I'm currently writing a helper function in VB.NET to convert an array of enum

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.