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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:26:16+00:00 2026-06-08T00:26:16+00:00

So basically here is my jQuery and HTML code for creating arrays. It basically

  • 0

So basically here is my jQuery and HTML code for creating arrays. It basically takes each div with class setting and checks wether it has span with attribute rel, if it has, it inserts in array under array. Each new div.settign span rel attributes will be inserted to another array under same parent array.

Check this code to understand it – http://jsfiddle.net/xVuHx/ .

Pasted it also here –

jQuery(document).ready(function() {
    var rel = [];
    jQuery(".setting").each(function() {
        rel.push(jQuery(this).find('span[rel]').map(function() {
            return this.getAttribute('rel');
        }).get());
    });               
    jQuery("body").text(rel);
});​

and html –

<div class="setting">
    <span rel="Variable">Variable</span>
    <span rel="Item">Item</span>
    <span rel="Something">Something</span>
</div>
<div>
    <span rel="Smth">Smth</span>
    <span>Sec</span>
</div>
<div class="setting">
    <span>Second</span>
    <span rel="first">First</span>
    <span rel="Third">Third</span>
</div>

it’s working great and displays two arrays – one with 3 elements and one with two, but when I try to pass it to PHP file via ajax, ti gives me [object Object] with var_dump($array); . Also I tried to do foreach, but it told me that invalid arguments were passed to foreach statement, so I guess I’m sending the array to ajax incorrectly or the Array is made incorrectly.

Here is my ajax code –

var myArray = jQuery(this).sortable("serialize") + "&type="+rel+"&action=update_homepage";
jQuery.post("'.admin_url("admin-ajax.php").'", myArray, function(response){
   var info = response.slice(0,-1);
});

This ajax code is made via wordpress, so its ajax requests differs a little bit from default AJAX requests.

Could you please check what exactly could be the problem?

EDIT:

Just tried to output with print_r($myArray); in php side, it outputs empty string.

  • 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-08T00:26:18+00:00Added an answer on June 8, 2026 at 12:26 am

    Check format of posted data in AJAX request in browser console (section network).

    You can find information about opening the console in your browser in this stackexchange question.

    JSON-js – JSON in JavaScript.

    To convert an object to JSON, use JSON.stringify:

    var json_text = JSON.stringify(your_object, null, 2);
    

    Encode your array to JSON and then send it with Ajax request. To decode JSON in PHP use json_decode

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

Sidebar

Related Questions

I'm using the JQuery DropdownChecklist as available from here: http://code.google.com/p/dropdown-check-list/ Basically I'm using some
Basically, here's my problem. I'm calling someone else's FORTRAN functions from my C++ code,
Here is my code... basically it finds any page-NUMBER- within a variable and then
Basically my problem is that i've adapted a piece of code found here http://social.msdn.microsoft.com/Forums/en-US/vemapcontroldev/thread/62e70670-f306-4bb7-8684-549979af91c1
here is the code: http://jsfiddle.net/hQnXm/7/ So basically i need when hover, it should animate
Here's the code I currently have. <!DOCTYPE html> <html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8/>
I have my form elements here: <li><div id=formanswer1 class=clonedInput>Answer: <input type=text id=formanswer1 value= /></div></li>
I'm using a simple jquery code that grabs html code form a tag and
here i have the following html, as it is basically match the following concept,
So I have found this code here This basically lets me pull some data

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.