14,17d13 < var lastone=0; < < var form=null; < var xhr=null; 20d15 < if (sois.value != '') { 22,26c17 < if (sois.value == ' ') { < clickit(document.getElementById('phpit')); < } else { < clickit(document.getElementById('ajaxit')); < } --- > clickit(); 35c26 < if (biggestsofar != 0 && eval('' + colis) != lastone && ('' + colis) != '5' && !earlierthere && document.getElementById('trcontent').innerText != '') { --- > if (biggestsofar != 0 && ('' + colis) != '5' && !earlierthere && document.getElementById('trcontent').innerText != '') { 37c28 < } else if (biggestsofar != 0 && eval('' + colis) != lastone && ('' + colis) != '5' && document.getElementById('trcontent').innerText != '' && eval('' + colis) <= biggestsofar) { --- > } else if (biggestsofar != 0 && ('' + colis) != '5' && document.getElementById('trcontent').innerText != '' && eval('' + colis) <= biggestsofar) { 48d38 < lastone=eval('' + colis); 69,71d58 < if (isNaN(yo)) { < cval='\"' + sois.value + '_' + colis + '\"' + ':\"' + yo.replace(/\[/g,'').replace(/\]/g,'').replace(/\\\"/g,'') + '\"'; < } else { 73d59 < } 81c67 < document.getElementById('thstart').innerHTML=\" \"; --- > document.getElementById('thstart').innerHTML=\"\"; 91d76 < } 94,111c79 < function clickit(bois) { < if (bois.id == 'ajaxit') { < form = new FormData(); < xhr = new XMLHttpRequest(); < xhr.onreadystatechange = function() { < if (this.readyState == 4 && this.status == 200) { < var myobj = JSON.parse(this.responseText); < var str=syntaxHighlight(myobj); //JSON.stringify(myobj, null, 2); < document.getElementById('result').innerHTML=\"

JSON.stringify(JSON.parse('\" + this.responseText + \"')) =

\" + str; < console.log(myobj); < } < }; < form.append('ajax', 'yes'); < form.append('injson', document.getElementById('trcontent').innerText); < xhr.open('post', 'json_code.php', true); < xhr.setRequestHeader('Cache-Control', 'no-cache'); < xhr.send(form); < } else { --- > function clickit() { 113d80 < } 116,136d82 < function syntaxHighlight(json) { // thanks to https://stackoverflow.com/questions/4810841/how-can-i-pretty-print-json-using-javascript < if (typeof json != 'string') { < json = JSON.stringify(json, undefined, 2); < } < json = json.replace(/&/g, '&').replace(//g, '>'); < return json.replace(/(\"(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\\"])*\"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) { < var cls = 'number'; < if (/^\"/.test(match)) { < if (/:$/.test(match)) { < cls = 'key'; < } else { < cls = 'string'; < } < } else if (/true|false/.test(match)) { < cls = 'boolean'; < } else if (/null/.test(match)) { < cls = 'null'; < } < return '' + match + ''; < }); < } 140c86 < $selstuff = " "; --- > $selstuff = " "; 150,156d95 < if (isset($_GET['ajax']) || isset($_POST['ajax'])) { < if (isset($_GET['injson'])) { < echo str_replace('+',' ',urldecode($_GET['injson']) ); < } else { < echo str_replace('+',' ',urldecode($_POST['injson']) ); < } < } else { 158c97 < echo "" . $cstyle . $jscr . "

Using PHP json_encode and json_decode or Ajax FormData and Javascript JSON.parse and JSON.stringify

RJM Programming

November, 2018

JSON in is " . str_replace('+',' ',urldecode($_GET['injson']) ) . "
"; --- > echo "" . $cstyle . $jscr . "

Using PHP json_encode and json_decode

RJM Programming

November, 2018

JSON in is " . str_replace('+',' ',urldecode($_GET['injson']) ) . "
"; 167c106 < echo "" . $cstyle . $jscr . "

Using PHP json_encode and json_decode or Ajax FormData and Javascript JSON.parse and JSON.stringify

RJM Programming

November, 2018

JSON in is " . str_replace('+',' ',urldecode($_POST['injson']) ) . "
"; --- > echo "" . $cstyle . $jscr . "

Using PHP json_encode and json_decode

RJM Programming

November, 2018

JSON in is " . str_replace('+',' ',urldecode($_POST['injson']) ) . "
"; 176d114 < } 178c116 < echo "" . $cstyle . $jscr . "

Using PHP json_encode and json_decode or Ajax FormData and Javascript JSON.parse and JSON.stringify

RJM Programming

November, 2018

" . $tablestuff . "
"; --- > echo "" . $cstyle . $jscr . "

Using json_encode and json_decode

RJM Programming

November, 2018

" . $tablestuff . "
";