Wuu Posted March 31, 2010 Report Share Posted March 31, 2010 <?php $res = json_decode($_REQUEST['data'], true); $send = array ('data'=>'i am php','say'=>$res); echo json_encode($send); ?> function send(data) { $.getJSON('jCore.php', { data: "i am json" }, function(json){ alert('php say: ' + json.data + ' ' + json.say); }); } Nespēju ar php nolasīti 'i am json' datus un nosūtīti tos atpakaļ, kur kodā kļūda? Visu laiku atbilde 'null' Quote Link to comment Share on other sites More sharing options...
codez Posted March 31, 2010 Report Share Posted March 31, 2010 debugo pa soļiem, sāc ar to vai requestā ir dati, tad vai pēc json_decode ir pareizi dati, utt. Quote Link to comment Share on other sites More sharing options...
Wuu Posted March 31, 2010 Author Report Share Posted March 31, 2010 $res ir tukšs Quote Link to comment Share on other sites More sharing options...
2easy Posted March 31, 2010 Report Share Posted March 31, 2010 varbūt izņem data no funkcijas argumenta? Quote Link to comment Share on other sites More sharing options...
codez Posted March 31, 2010 Report Share Posted March 31, 2010 $res ir tukšs nu tad mēģini $_GET['data']; Quote Link to comment Share on other sites More sharing options...
Wuu Posted March 31, 2010 Author Report Share Posted March 31, 2010 Šādi strādā! $send = array ('data'=>'i am php','say'=>$_REQUEST['data']); Tad kāda velna pēc ir vajadzīgs $res = json_decode($_REQUEST['data'], true); ? Kurš neatgriež neko? Vai arī mans manuālis ir fake and gay? Quote Link to comment Share on other sites More sharing options...
codez Posted March 31, 2010 Report Share Posted March 31, 2010 (edited) Principā šijā gadījumā tu jau to json_decode taisi stringam, kam normālā gadījumā vajadzētu atgriezt to pašu stringu. man: $res = json_decode('i am json', true); echo $res; //i am json Edited March 31, 2010 by codez Quote Link to comment Share on other sites More sharing options...
Wuu Posted March 31, 2010 Author Report Share Posted March 31, 2010 Tad sanāk, ka es varu arī iztikti bez json_decode? Quote Link to comment Share on other sites More sharing options...
codez Posted March 31, 2010 Report Share Posted March 31, 2010 ja sūti vienkāršu stringus tad, jā. json_decode būtu vajadzīgs, ja tu sūtītu json datus, piemēram: $.getJSON('urlis',{data:{a:1,b:2}},function(d){}); Quote Link to comment Share on other sites More sharing options...
Wuu Posted March 31, 2010 Author Report Share Posted March 31, 2010 Liels paldies! p.s. codez tev 1000 posti :D Quote Link to comment Share on other sites More sharing options...
2easy Posted March 31, 2010 Report Share Posted March 31, 2010 viņš tagad ir pro ;) Quote Link to comment Share on other sites More sharing options...
codez Posted March 31, 2010 Report Share Posted March 31, 2010 dažreiz iemetu acis:Top psters 2easy vienmēr ir 1. vietā. Quote Link to comment Share on other sites More sharing options...
2easy Posted March 31, 2010 Report Share Posted March 31, 2010 spameri vnm ir topā ^^ Quote Link to comment 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.