Pregunta

how to transfer html content ? eg:

<script>
$(function(){
    $('#actBtn').click(function(){
        var txt = $('#quick_links').html();
        $.post('/services.php','actBtn=save&content=' + txt + '&v=' + Math.random(),function(data){ });
    });
})

and in div#quick_links, there are some a links : http://domain.com?parem=1&time=123345#rw2 as you saw, the html content contains some special signs (",#,&), how to deal with them , especial "&" ?

thanks

¿Fue útil?

Solución

You need to URLencode your postdata or let jQuery do it:

$(function() {
    $('#actBtn').click(function() {
        var txt = $('#quick_links').html();
        $.post('/services.php', {
            actBtn: "save",
            content: txt,
            v: Math.random()
        }, function(data) {});
    });
})
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top