nandhakumar nandhakumar - 6 months ago 30
PHP Question

send the values of ckeditor using ajax it diaplays only few lines

ckeditor contents will completely get in script.i can check this via alert.

var ckpost=CKEDITOR.instances['content'].getData();
alert(ckpost);
$.ajax({
type: "POST",
url: "addpost.php",
data: "ckpost=" + ckpost,
success: function(msg){ }
});


enter image description here

after this alert i am send the values of ckpost to another page using ajax.but in my addpost.php i can get only few lines of this ckpost.

enter image description here

$post =$_POST['ckpost'];
echo $post;


These codes are used in my addpost.php.How can i get these complete values usingajax.

Answer

Your request data is not properly encoded, you can use encodeURIComponent

$.ajax({  
        type: "POST",  
        url: "addpost.php",  
        data: "ckpost=" + encodeURIComponent(ckpost),  
        success: function(msg){  }
});

or pass an object as the data parameter

$.ajax({  
        type: "POST",  
        url: "addpost.php",  
        data: {"ckpost": ckpost},  
        success: function(msg){  }
});

to have the request be properly encoded.

Comments