Welcome Guest, Not a member yet? Register   Sign In
encoding problam with jquery
#1

[eluser]A.M.F[/eluser]
hello mates

i want to make an add-comments-form with jQuery.
therefore i writed this JS:

Code:
$(document).ready(function() {

        $("#commentF").submit(function () { return false; });                      
        $("#comment input[@type='submit']").click(function(){
              $.post("<?=site_url_rel("show/comment/".$game_id)?>", {content: $("textarea").val()}, function(xml) {
                var content = $("textarea").val();
                $("#comment").html(
                "התגובה התווספה בהצלחה"
                );
            });
        });
    });

now, this is my html:

Code:
<div id="comment" style="display:block; float:right; width:30%; margin-right:15px;">
<h1>הוספת תגובה</h1><br />
&lt;form id="commentF" method="post"&gt;
<br />&lt;textarea name="content" maxlength="300" class="big_txt" value="sdf"&gt;עברית&lt;/textarea&gt;
<br />&lt;input type="submit" name="send" value=" שלח תגובה " /&gt;
&lt;/form&gt;
</div>

and that the php code inside my controller:

Code:
function comment($item_id)
{
    header('Content-Type: text/html; charset=windows-1255');

    $comment = $this->input->post('content', TRUE);
    //if (trim($comment) == "") show_error("עלייך לכתוב תגובה ישמוק");

    $data = array('cmnt_itemid'     => $item_id,
              'cmnt_item'     => 'game',
              'cmnt_content' => $comment,
              'cmnt_date'     => 'היום'
    );
    $this->db->insert('comments', $data);
    return true;
}

everything is ok, BUT- the $comment data that i get is in japanease or whatever, even though i added a header with my encoding. why is that?

thank u guys
#2

[eluser]xwero[/eluser]
your return true instead of a string, the data your get will be the javascript version of the php true boolean.
#3

[eluser]A.M.F[/eluser]
[quote author="xwero" date="1204834685"]your return true instead of a string, the data your get will be the javascript version of the php true boolean.[/quote]

the return value doesn't matter, i can also remove the 'return' cuz i don't need it.
i am inserting the data into the DB before i am returning any value.

the problam is only the text that i get from the POST.
#4

[eluser]A.M.F[/eluser]
anyone? i'm really hopeless right now =[
#5

[eluser]Avatar[/eluser]
I think you must set the header:
Code:
header('Content-Type: text/html; charset=windows-1255');
on the page that sends to this comments function (the page making the POST to this one) and it should fix your problem

also maybe try a different charset
#6

[eluser]A.M.F[/eluser]
[quote author="yingyes" date="1204847200"]I think you must set the header:
Code:
header('Content-Type: text/html; charset=windows-1255');
on the page that sends to this comments function (the page making the POST to this one) and it should fix your problem

also maybe try a different charset[/quote]

allready tried that... not working.




Theme © iAndrew 2016 - Forum software by © MyBB