JSON serialization in javascript and php deserialization -


Hello I have problems with deserialization of serialized JSON in JavaScript. I have a form on the webpage and every line is a product (inputs, picks, checkboxes):

  name, value, total math, ... name 2, value 2 , Total count 2, .... ..  

I take a form and serialize it with javascript (function jjaxload is normal, jquery foundation is $ .ajax (...) and it is in other places correctly Works)

  var form = $ ('# myForm'); Formksubmit (function (event) {event.preventDefault (); ajaxLoad (form.attr ( 'action'), form.parent (), {jsonData: JSON.stringify (form.serializeArray ())});}) ; In php, the data has been received and my code is the following:  
  $ data = json_decode ($ jsonData, true); $ This- & gt; Template-> Data = print_a ($ data, 1);  

returns something like this:

  array ([0] => array ([name] => product [0] [cor_projectProduct_name ] [value] = & gt; 1ks Replika Kádnerova jáchymovského stand tolaru BJ) [1] = & gt; array ([name] = & gt; products [0] [url] [value] = & gt; http : // some-good-url.ccz) [2] = & gt; array ([name] => products [0] [cor_projectProduct_ean] [value] => [3] = & gt; array ([name] = & gt; products [0] [cor_projectProduct_internalCode] [value] = & gt;) [4] = & gt; array ([name] = & gt; products [0] [cor_project_id] [value] = & Gt; 6) [5] = & gt; array ([name] = & gt; product [0] [cor_projectProduct_keywordAllowed] [value] = & gt;) ...  

But the object of me Arrays to be arrayed.

I used to sort the form with three form.serialize , but the return result was too bad - the urlencoded string, which I could not decode.

When I tried to send the post method through the post method as the array and then read it from $ _ POST to php, but it worked but Due to the post limit, some data was lost, so it was form of serialized string Posting is better, t know how and how it deserialize in php

Edit: OK, maybe it was explained badly, what is the need of me as a result of the array of things:

  Arre ([0] = & gt; stdClass object ([cor_projectProduct_name] = & gt; 1ks Replika Kádnerova jáchymovského tolaru stand BJ [url] = & gt; http://www.ceske-mince.cz / Sska_minkovna / 1997 / replica-Kdnerova-Jcyamvskeho-Tolru-stand / [Kr_projektprodkt_ayn] = & gt; [Kr_projektprodkt_internlkde] = & gt; [Kr_projekt_id] = & gt; 6 [Kr_projektprodkt_keywardlloved] = & gt; ...) [1 ] = & gt; stdClass object ([cor_projectProduct_name] = & gt; 1ks Replika Kádnerova jáchymovského tolaru stand BJ ...) ...  

or Number of associative arrays This is the same thing, it does not matter

To get an object instead of an orgade,

  $ data = json_decode ($ jsonData, 

$ json_decode ($ JsonData, true) False);

Demo:


Comments

Popular posts from this blog

c# - SignalR: "Protocol error: Unknown transport." when navigating to hub -

c# - WPF Expander overlay used in ItemsControl -

class - Kivy: how to instantiate a dynamic classes in python -