1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Using JQuery (AJAX) to save TinyMCE to Database?

Discussion in 'jQuery' started by mokimofiki, Mar 8, 2012.

  1. #1
    I currently have some code that breaks no matter how I try to run it when saving TinyMCE to a database (never gets to the database part). What happens is if I create a hyperlink within the Textarea the AJAX breaks and reloads the page with values in the url.

    This is what I have currently for the AJAX method to process the form with TinyMCE within it:
    <!-- PROCESS FORM ON SUBMISSION -->
                    <script>
                    $(function() {  
    				  $(".buttonsubmit").click(function() { 
    					//tinyMCE.get('blogdescription').save();
    					var ed = tinyMCE.get('blogdescription');
    					
    					var company_id = $("#company_id").val();
    					var blogtitle = $("#blogtitle").val();
    					var blogimage = $("#blogimage").val();
    					var blogurl = $("#blogurl").val();
    					var blogstatus = $("#blogstatus").val();
    					var blogdescription = escape(ed.getContent());
    					alert(blogdescription);
    					
    					var dataString = 'company_id='+ company_id + '&blogtitle=' + blogtitle + '&blogimage=' + blogimage + '&blogurl=' + blogurl + '&blogstatus=' + blogstatus + '&blogdescription=' + htmlEntities(ed.getContent());
    						$.ajax({  
    						  type: "GET",  
    						  url: "blog-add.php",
    						  content_type : "application/x-www-form-urlencoded",
    						  data: dataString,  
    						  success: function() {  
    							$('#status').html("<div id='message'></div>");  //replaced div id status with a new div
    							$('#message').html("<h2 style='color:#92B22C; margin:10px 0 0 0;'>Blog Added Successfully!</h2>")  //adds content to the message div
    							.hide()  
    							.fadeIn(1500, function() {
    							});
    							
    							$('#blogtitle').val("");
    							$('#blogimage').val("");
    							$('#blogurl').val("");
    							$('#blogstatus').val("");
    							$('#blogdescription').val("");
    							
    						  }  
    						});  
    						return false;
    					
    				  });
    				});
    				</script>
                    <!-- END FORM PROCESSING -->
    Code (markup):

     
    mokimofiki, Mar 8, 2012 IP
  2. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #2
    So we have narrowed it down to the http within the variable. if we create a relative link everything transfers and saves fine although when adding http:// to the hyperlink breaks the ajax. Any thoughts?
     
    mokimofiki, Mar 8, 2012 IP
  3. mokimofiki

    mokimofiki Well-Known Member

    Messages:
    444
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    130
    #3
    If anyone has insight to this I would still love to hear from you although for the time being we just used the javascript replace function to remove the http before sending the AJAX request and add it back when the post is displayed.
     
    mokimofiki, Mar 8, 2012 IP