after ajax form submit value from ckeditor textarea is not sent through post

after ajax form submit value from ckeditor textarea is not sent through post



i have a form having some textfields and a textarea (ckeditor), after onclick button art_title field value is sent to art_save.php page, but value from textarea is not sent.


<script src="ckeditor/ckeditor.js"></script>
function saveArt()

var title = document.getElementById('art_title'),
art_title = title.value;

var desc = document.getElementById('art_body'),
art_body = desc.value;

jQuery.ajax(
type: 'POST',
url: 'art_save.php',
data:
title: art_title,
aut: art_author,
tag: art_tag,
desc: art_body



);
return false;




html part


<form method="post" name="art" id="art">
<input type="text" id="art_title" name="art_title" placeholder="Here goes your title"/>
<textarea class="ckeditor" name="art_body" id="art_body"></textarea>
<input type="submit" name="savedraft" id="savedraft" onclick="saveArt();return false;" value="Need more Research ! Save as Draft" class="button"/>
</form>





Just check in jsfiddle, works file. jsfiddle.net/aqpqf1m5 . Possible you forgot some important detail.
– Vartlok
May 22 '15 at 13:32




4 Answers
4



You can force CKeditor to update the textarea value using:


for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].updateElement();



Also, you can use .serialize for the data - then you won't have to maintain the AJAX code if parameters change:


.serialize


<script src="ckeditor/ckeditor.js"></script>
function saveArt()

for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].updateElement();


jQuery.ajax(
type: 'POST',
url: 'art_save.php',
data: $("#art").serialize()
);
return false;






Thanks buddy , code worked,, just added for (instance in CKEDITOR.instances) CKEDITOR.instances[instance].updateElement(); now its saving textarea field value ,, thank you again. @Carl
– user3099225
May 22 '15 at 14:12



for (instance in CKEDITOR.instances) CKEDITOR.instances[instance].updateElement();





Thanks! You saved my day. Also, thanks to Chinmay!
– aagjalpankaj
Jun 8 '17 at 11:56


for (instance in CKEDITOR.instances)

CKEDITOR.instances[instance].updateElement();


$.ajax(
url: "controllers/c.publicidad.php?task=save",
type: 'post',
data: $("form[name='form']").serialize(),
dataType: 'json',
success: function(data)
if(data.idenvio != '')
$("form[name='frmPublicidad']").toggle("slow");
$("#MessageSuscripcion").html(data.message);


);





thanks all for help :)
– user3099225
Jan 11 '16 at 6:46





just logged in to say thanks :) saved my day
– black
Oct 5 '17 at 13:02



you can get html form ckeditor with this :


var art_body = CKEDITOR.instances.art_body.getData();



This is what worked for me:


$.ajax(

type: "POST",
url: path+"/html-action",
data: data1: dataone,
data2: datatwo,
data3: datathree,
data4: datafour,
message: ckeditortxt,
cache: true,
success: function(html)





Initially, I was using a datastring to pass information, but for some reason, the element that holds the ckeditor data was not being considered as a parameter. So I split all the parameters to individual components i.e. data1 data2, data3, data4.... and this time, it worked



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

Node.js puppeteer - Use values from array in a loop to cycle through pages