Petani Posted August 5, 2012 Share Posted August 5, 2012 hi all. i have problem with tinymce n jquery, i use tinymce for textarea below: i have form like this: <div id="out_form_login"> </div> <div id="form_profile"> <form> <table> <tr> <td class="title">My Profile</td> </tr> <tr> <td> <textarea name="profil_my" cols="100" rows="25"> </textarea></td> </tr> <tr> <td align="right"> <input type="submit" name="save_profil" value="save"> </td> </tr> </table> </form> </div> i have jquery ajax: $('#form_profile form').submit(function() { $('#out_form_login').empty(); $.post('save_profile.php',$(this).serialize(),function(data) { $("#out_form_login").show(); $('#out_form_login').html(data); }); return false; }); when i try to click save button to save the text in textarea(using tinymce) to DB, it didn't work, but when i click the save button once again, it works. i confuse how could this happen. is something wrong with my code?? thanks b4. Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/ Share on other sites More sharing options...
jazzman1 Posted August 5, 2012 Share Posted August 5, 2012 If you want an event to work on your page, you should call it inside the $(document).ready() function. Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367047 Share on other sites More sharing options...
Petani Posted August 6, 2012 Author Share Posted August 6, 2012 oh ya friend, i forget to add, $(document).ready() function, this is the true: $(document).ready(function() { $('#form_profile form').submit(function() { $('#out_form_login').empty(); $.post('save_profile.php',$(this).serialize(),function(data) { $("#out_form_login").show(); $('#out_form_login').html(data); }); return false; }); }); it's still the same, i have to click twice save button to save the data. Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367076 Share on other sites More sharing options...
jazzman1 Posted August 6, 2012 Share Posted August 6, 2012 You must define a post method in your html form, by default it's a GET method. In your js script you use jquery post method. $.post('save_profile.php',$(this).serialize(),function(data) Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367115 Share on other sites More sharing options...
Petani Posted August 6, 2012 Author Share Posted August 6, 2012 thanks for the response my friend, so you mean, just like this? <div id="out_form_login"> </div> <div id="form_profile"> <form method="POST"> <!-- add POST method --> <table> <tr> <td class="title">My Profile</td> </tr> <tr> <td> <textarea name="profil_my" cols="100" rows="25"> </textarea></td> </tr> <tr> <td align="right"> <input type="submit" name="save_profil" value="save"> </td> </tr> </table> </form> </div> it's still the same, i have to click save button twice to save it to DB successfully. i've tried to non-active tinymce, n become textarea normal , it works to save with just one click, but back, i active tinymce, it's back to its problem. Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367238 Share on other sites More sharing options...
jazzman1 Posted August 6, 2012 Share Posted August 6, 2012 I've checked your script and the form has been submitted in the way, I expected to be. Do you use any js debuger tools ? Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367290 Share on other sites More sharing options...
Petani Posted August 7, 2012 Author Share Posted August 7, 2012 oh ya, have u tried saving texts in textarea(using tinymce) via ajax just like above?? i dont know js debugger? is that really helping my friend? so, what's the best js debugger u know friend, Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367396 Share on other sites More sharing options...
Petani Posted August 7, 2012 Author Share Posted August 7, 2012 hi friend, i have found the way to solve it. i just add tinyMCE.triggerSave(); so my ajax can be like this: $(document).ready(function() { $('#form_profile form').submit(function() { tinyMCE.triggerSave(); $('#out_form_login').empty(); $.post('save_profile.php',$(this).serialize(),function(data) { $("#out_form_login").show(); $('#out_form_login').html(data); }); return false; }); }); thanks for friend jazzman1 for trying to help me. .... really helpful,... Quote Link to comment https://forums.phpfreaks.com/topic/266710-problem-tinymce-with-ajax-jquery/#findComment-1367407 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.