Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9218411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:51:29+00:00 2026-06-18T02:51:29+00:00

I am using Ajax to submit the info entered into the textarea, and trying

  • 0

I am using Ajax to submit the info entered into the textarea, and trying to have the page load the string that was submitted. I got rid of the errors and am getting the success function to display, but the results aren’t loading on the page. WHat am I doing wrong?

            var dataString = tinyMCE.get('addAnswer').getContent();

            $.ajax({
                type: "POST",
                url: "/home/19/1/add_answer/",
                data: $(dataString).serialize(),
                success: function(data){
                    alert(dataString);
                },
                error: function(){
                    alert('You fail');
                }
            });

Here’s the full code:

$('#submitAnswer').on('click', function(e){
            e.preventDefault();
            var dataString = tinyMCE.get('addAnswer').getContent();


        // Next 3 functions are all for the csrf token
            function getCookie(name) {
                var cookieValue = null;
                if (document.cookie && document.cookie != '') {
                    var cookies = document.cookie.split(';');
                    for (var i = 0; i < cookies.length; i++) {
                        var cookie = jQuery.trim(cookies[i]);
                        // Does this cookie string begin with the name we want?
                        if (cookie.substring(0, name.length + 1) == (name + '=')) {
                            cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                            break;
                        }
                    }
                }
                return cookieValue;
            }
            var csrftoken = getCookie('csrftoken');

            function csrfSafeMethod(method) {
                // these HTTP methods do not require CSRF protection
                return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
            }
            function sameOrigin(url) {
                // test that a given url is a same-origin URL
                // url could be relative or scheme relative or absolute
                var host = document.location.host; // host + port
                var protocol = document.location.protocol;
                var sr_origin = '//' + host;
                var origin = protocol + sr_origin;
                // Allow absolute or scheme relative URLs to same origin
                return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
                    (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') ||
                    // or any other URL that isn't scheme relative or absolute i.e relative.
                    !(/^(\/\/|http:|https:).*/.test(url));
            }
            $.ajaxSetup({
                beforeSend: function(xhr, settings) {
                    if (!csrfSafeMethod(settings.type) && sameOrigin(settings.url)) {
                        // Send the token to same-origin, relative URLs only.
                        // Send the token only if the method warrants CSRF protection
                        // Using the CSRFToken value acquired earlier
                        xhr.setRequestHeader("X-CSRFToken", csrftoken);
                    }
                }
            });

            // End of csrf token functions

            $.ajax({
                type: "POST",
                url: "/home/19/1/add_answer/",
                data: $(dataString).serialize(),
                success: function(data){
                    alert(dataString);
                },
                error: function(){
                    alert('damn');
                }
            });
        });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:51:31+00:00Added an answer on June 18, 2026 at 2:51 am

    Select any html element inside the page to load the data which is received inside the success function as shown below.

    $.ajax({
       type: "POST",
       url: "/home/19/1/add_answer/",
       data: $(dataString).serialize(),
       success: function(data){
                 alert(dataString);
                 $("#test").html(data); // replace 'test' with your selected element id
                },
       error: function(){
                  alert('You fail');
                }
     });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to submit my Ajax form using jQuery. However calling the submit() function
I'm using ajax to submit a contact from without reloading the page, it works
Hi I have used this tutorial http://net.tutsplus.com/tutorials/javascript-ajax/submit-a-form-without-page-refresh-using-jquery/ to create php - jquery - ajax
I have several contact forms using the same general AJAX code: $(document).ready(function() { $('#mainMail').submit(
I have a div that is generated html via Expression Engine. I'm using ajax
I'm creating a basic form with ajax submit using jquery framework. This is my
I am using Ajax to receive a JSON update: $(document).ready(function(){ $('form').submit(function(event){ event.preventDefault(); var form
I want to render the partial view using ajax. When I submit the button,
I am using railo and attempting to submit a tinymce text area via ajax.
I am using the following code to submit different values var evalue= 'color:#d32;font-size:12px;'; jQuery.ajax({

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.