[jQuery] Re: What is the best way to send data betwen JS - PHP

2008-06-20 Thread Konstantin Tokar

 but sometimes text contains \ or another istrange characters and not like
 to be correct send data in this way.
 ¿what is the best way? PHP - JS I use json, but for JS-PHP?

JSON!!!


function KT_RPC(subname, data, on_success, on_error){
jQuery.ajax({
'type': POST,
'url': /RPC.php,
'data':
{
'subname' : subname,
'json' : jQuery.toJSON(data)
},
success: function(data){
   var data_decoded = jQuery.parseJSON(data);
   if( typeof on_success == 'function'){
 on_success(data_decoded);
   }
   ...
},
 ...
);
}

KT_RPC(
  'test_sub',
  {name:value,name:value...},
  function (data){...},
  function (...){...}
);


[jQuery] Re: What is the best way to send data betwen JS - PHP

2008-06-19 Thread mmw

Use a Json serialization

script.php?request=s:e:r:i:a:l:i:z:a:t:i:o:n

only one parameter by script, then you parse the request
it's called RPC, as well as the question the answer (if needed) should
have the same shape
it's also called IPC at kernel level, you can also use url_encode...

Cheers!

On Jun 19, 4:01 am, Harlok [EMAIL PROTECTED] wrote:
 Hi, I use POST for send all data to a PHP scrip, for ex:

 data:script.php?id=+id+text=+text,

 but sometimes text contains \ or another strange char and I think
 that is not the better way for send data.
 ¿what is the best way? PHP - JS I use json, but for JS-PHP?

 Thanks


[jQuery] Re: What is the best way to send data betwen JS - PHP

2008-06-19 Thread Isaak Malik
There isn't really a best method, but if you're using GET then you should
always convert your special characters to URI safe characters using:
encodeURIComponent().

For sensitive data it's better to use POST.

On Thu, Jun 19, 2008 at 12:51 PM, Aaron [EMAIL PROTECTED] wrote:

 Hi, I use POST for send all data to a PHP scrip, for ex:

 data:script.php?id=+id+text=+text,

 but sometimes text contains \ or another istrange characters and not like
 to be correct send data in this way.
 ¿what is the best way? PHP - JS I use json, but for JS-PHP?


 --
 Asterisk ext: 13502
 Asterisk server: null-lab.homelinux.org
 GPG Key ID 0x9ED66FA7
 Key Fingerprint: 3674 956F E2DF DC3B 694C 5281 6D57 5656 9ED6 6FA7




-- 
Isaak Malik
Web Developer