> 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 (...){...}
);

Reply via email to