AJAX sending html content in half

0

I'm having a problem with the publishing system.

When I'm going to make a new post and fill in all the fields: Title, photo and publication the code var myArea2 = document.getElementById('myArea2'); var post = myArea2.innerHTML; takes the entire html element inside the div with id myArea2 until then it I actually get everything, but when I send ajax to another php page where it gets $_POST it prints myArea2 content to half .

It's like ajax has been sending in half, NOT ALL content.

function enviarPost() {
            var url_s = "<?php print $url_s; ?>";

            var myArea2 = document.getElementById('myArea2');
            var post = myArea2.innerHTML;

            var now_date = document.getElementById('now_date');
            var data = now_date.innerHTML;

            var now_autor = document.getElementById('now_autor');
            var autor = now_autor.innerHTML;

            var title = $('#title_post').val();

            var result_i = document.getElementById('result_i');
            var img = result_i.innerHTML;

            if(post != '' || title != '' || img != '') {
                var dataString = 'title='+title+'&data='+data+'&autor='+autor+'&img='+img+'&post='+post+'&type=postagem';
                $.ajax({
                    type: "POST",
                    url:  url_s+"server/teste.php",
                    data: dataString,
                    cache: false,
                    success: function(tihidResponse){
                        $("#sample").html(tihidResponse);
                    }
                });
            } else {
                alert("Todas as informações tem de estar preenchida: Titulo, imagem e texto de postagem.");
            }
        }

What should be a complete publication:

Returnsonlythebeginningofthepost,asifitonlytookthefirsttagoftheHTMLcontentsent.

Doesanyonehaveasolution??

Itriedwithtype:"GET" for ajax, but gave% error of%.

    
asked by anonymous 22.08.2015 / 17:29

1 answer

1

The GET would not work, it has limits on the size of the sent string.

Try changing this:

var dataString = 'title='+title+'&data='+data+'&autor='+autor+'&img='+img+'&post='+post+'&type=postagem';

So:

var dataString = { 
    title: title,
    data: data,
    autor: autor,
    img: img,
    post: post,
    type: postagem
};

Of course in your PHP you will have to adapt, but in principle will send everything.

    
22.08.2015 / 18:45