tags:

views:

17

answers:

3
<script type="text/javascript">
    function testing() {

        $.ajax({
           type: "POST",
           url: "testing.php",     
           data: "call="+$("#abc").val(),
           success: function(msg){  
            alert( msg );
           }
        });
    }
</script>
<textarea id="abc" cols="" rows=""></textarea>

I want to post the data to testing.php but if i got special characters like & sign. it will create the problem. How do i go about it?

Thank You

A: 

URL encode those characters.

& = &amp;
Dustin Laine
A: 

In your testing.php file you can use the function addslashes before the data that contains text.

Sarfraz
+1  A: 

Use encodeURIComponent:

<script type="text/javascript">
function testing() {

    $.ajax({
       type: "POST",
       url: "testing.php",     
       data: "call=" + encodeURIComponent($("#abc").val()),
       success: function(msg){  
        alert( msg );
       }
    });
}
</script>
Michael Dean