Hello Christophe, Hello Ken,
i use atm FF2.0, but i want a compatibility for I.E.also etc.
When i use your simple object:
> new Ajax.Request('server.php',
> {
> method: 'post',
> parameters: {
> method: 'foo::bar',
> params: data,
> id: new Date().getTime()
> }), ...
the first chars in my string would be correct, but not the followings,
the result look like this:
{"method%22%3A%22foo%3A%3Abar%22%2C%22params%22%3A%
I worked with another solution now. I use my javascript code like
before:
new Ajax.Request('server.php',
{
method: 'post',
parameters: JSON.stringify({
method: 'foo::bar',
params: [data],
id: new Date().getTime()
}),
onSuccess:doSomething,
onFailure: function(){ alert('Something went wrong...') }
});
But new is my little solution on the server side, i will tell, it's
simple but it will works:
function hex2str($hex) {
$str = ''; $loop = 1;
for($i=0; $i<strlen($hex); $i+=$loop) {
$chr = substr($hex,$i,1);
if($chr=='%') { // found next hex
$chr = substr($hex,$i+1,2);
$str .= chr(hexdec($chr));
$loop = 3;
}
else { // next char
$str .= $chr;
$loop = 1;
}
}
return substr($str,0,strlen($str)-1); // kill the last "=", little
bug
}
And now, i receive the string, decode it firstly with hex2str, before
it decode as a JSON objekt:
$string = hex2str(file_get_contents('php://input'));
$objJSON=json_decode($string);
What would you think, is it a terrible solution? Or is it acceptable?
Thanks for you help Christophe and Ken
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---