manix Posted August 11, 2011 Share Posted August 11, 2011 Alright, I read like 500 articles and threads about this and none of them worked. I have a string of cyrillic characters which I need to pass to another page via post ajax which apparently does not support cp1251 charset so I figured I needed to encode the string before passing it, and I did utf8_encode and guess what, it didn't work because that encodes cyrillic characters to some other cyrillic looking characters and when they're being passed via post they become something like "PPP?!?PPP". So my question is what encoding do I need to use to pass cyrillic characters with jquery post ajax Quote Link to comment https://forums.phpfreaks.com/topic/244481-encode-string/ Share on other sites More sharing options...
WebStyles Posted August 11, 2011 Share Posted August 11, 2011 doesn't sound like a php question. Maybe you'll have better luck in the javascript or ajax forum. Anyway, you should post your code so we can have a look. thanks Quote Link to comment https://forums.phpfreaks.com/topic/244481-encode-string/#findComment-1255734 Share on other sites More sharing options...
manix Posted August 11, 2011 Author Share Posted August 11, 2011 well It's all mixed.. <?php if(isset($_POST['search'])) { $search = $_POST['search']; // this is the correct string which I send from a form in another page ..here I echo some stuff.. ?> <script type="text/javascript"> $.post('vicove.php', { page: 1, order: 4, search: $('#searchhidden').val() // this is still the correct string }, function(returned) { if(returned.length>100) { $('#results').html(returned).show(); } }); </script> <?php } ?> here's the part where it messes up vicove.php <?php .... $ordernumber=$_POST['order']; switch($ordernumber) { case 4: $viewuser = $_POST['search']; // alright here is the problem, now it's ruined ... ?> Quote Link to comment https://forums.phpfreaks.com/topic/244481-encode-string/#findComment-1255739 Share on other sites More sharing options...
manix Posted August 11, 2011 Author Share Posted August 11, 2011 Solved, used urlencode() and urldecode() sending $.post('vicove.php', { page: 1, order: 4, param1: "<?php echo urlencode($search); ?>" }, function(returned) { if(returned.length>100) { $('#results').html(returned).show(); } }); receiving <?php $search = urldecode($_POST['param1']); ?> Quote Link to comment https://forums.phpfreaks.com/topic/244481-encode-string/#findComment-1255781 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.