Destramic Posted September 12, 2015 Share Posted September 12, 2015 hey guys i have a data attribute with a json string of about 291478 characters long so far and counting...but im thinking the data attribute has a max length (although im unable to find any details on this so far) as my json string gets cut off 3/4's of the way through when i echo string outside data attribute it shows perfectly fine...does anyone know the max length? also i need to find somewhere else to store this json string...the data attribute had been perfect up until now! Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/ Share on other sites More sharing options...
QuickOldCar Posted September 13, 2015 Share Posted September 13, 2015 Data attributes are unlimited but do have limits due to system memory. You should consider these more like meta fields and output data normally. Strings have a limit of 2GB but the overall script execution also has a limit determined by your php.ini memory settings and also server resources. If you are having memory issues you may want to rethink how are fetching and displaying the data. json_decode() the json file and store data into a database Can read from saved json files directly like a cache but have to load the entire file each time and parse it. Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520747 Share on other sites More sharing options...
Destramic Posted September 13, 2015 Author Share Posted September 13, 2015 well the data originally comes from the database then i use public function encode($data = array()) { $utf8 = new UTF8(); $data = $utf8->encode($data); $json = json_encode($data); $json = htmlentities(stripslashes($json), ENT_QUOTES); return $json; } to encode to json so i can use the data via js....and i call the data like so: sub_category.data('sub-categories'); the after encoded the json looks like a perfect json string....but when added to the data attribute it only has about 3/4 of the data and not formed correctly Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520756 Share on other sites More sharing options...
Destramic Posted September 13, 2015 Author Share Posted September 13, 2015 ok i put my json data in the meta tag and got it via js $("meta[name='sub-sub-categories']").attr('content'); now i have the same problem...i get only 2500 rows and then it cutts off =/ Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520757 Share on other sites More sharing options...
QuickOldCar Posted September 13, 2015 Share Posted September 13, 2015 (edited) Really...2500 rows then cut, all this data needs to be displayed all one time? It's hard for me to envision why you need to do this. Possibly unescaped encoding issue Have any examples of the data where it gets cut off? Edited September 13, 2015 by QuickOldCar Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520758 Share on other sites More sharing options...
Destramic Posted September 13, 2015 Author Share Posted September 13, 2015 (edited) ok well this is embarrassing my json isn't valid basically i have 3 columns like so: "name":"10" Singles" 10" Singles - but because of the quote make which represents inch, json fails. strip slashes worked like a charm....thank you Edited September 13, 2015 by Destramic Quote Link to comment https://forums.phpfreaks.com/topic/298145-data-attribute/#findComment-1520761 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.