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 9060447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:13:58+00:00 2026-06-16T15:13:58+00:00

In part of a jquery code I have this line of code below: var

  • 0

In part of a jquery code I have this line of code below:

 var newHtml="<span style='color: green'>"+result.msg+"</span>"

Now the jquery code is displayed in the <body> section but the problem is that I am getting an error in my validation stating:

document type does not allow element “span” here

My question is that is there a way to fix it while keeping the span tag or do I need to use an alternative?

Full code form the View source:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title>Edit Assessment Date/Start Time</title>
        <link rel="stylesheet" type="text/css" href="edit_sessionadminStyles.css"/>
        <link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-1.8.16.custom.css"/>
        <script type="text/javascript" src="jquery/jquery-1.7.min.js"></script>
        <script type="text/javascript" src="jquery/jquery-ui-1.8.16.custom.min.js"></script>

        <link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery.ui.timepicker.css"/>
        <link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-1.8.14.custom.css"/>
        <link rel="stylesheet" type="text/css" href="jquery/ui-lightness/jquery-ui-timepicker-addon.css"/>
        <script type="text/javascript" src="jquery/jquery.ui.timepicker.js"></script>
        <script type="text/javascript" src="jquery/jquery-ui-timepicker-addon.js"></script>

        </head>
        <body>

    <script type="text/javascript">


     function submitform() {    

        $.ajax({
            type: "POST",
            url: "updatedatetime.php",
            data: $('#updateForm').serialize(),
            dataType:'json',  //get response as json
            success: function(result){
                        if(result.errorflag){

           //do your stuff on getting error message
          var newHtml="<span class='red'>"+result.msg+"</span>"; 
          $("#targetdiv").html(newHtml);  //i am displaying the error msg here

        }else{
           //you got success message

           var newHtml="<span class='green'>"+result.msg+"</span>"; 
                $("#targetdiv").html(newHtml);
                //Get and store the new date and time.
                    var newDate = jQuery("#newDate").val();
                    var newTime = jQuery("#newTime").val();

                    //Set your current date and time to your new date and time.
                    jQuery("#currentDate").val(newDate);
                    jQuery("#currentTime").val(newTime);

                    //Find the currently selected session and update it.
                    var selectedOption = jQuery("#sessionsDrop option:selected");
                    var label = selectedOption.text().split(" - ");
                    selectedOption.text(label[0] + " - " + newDate + " - " + newTime);

                    //Clear the new date and time fields.
                    jQuery("#newDate").val("");
                    jQuery("#newTime").val("");

                    $('#targetdiv').show();
            }
        }
      });        
    }



    $('body').on('click', '#updateSubmit', showConfirm);       


    </script>   

   <noscript style='color: red'><img src="Images/warning-2.fw.png" alt="Javascript Warning" id="warningImage" name="warningSymbol"/> In order to use this application without any problems, you must have javascript enabled</noscript>
Please Login to Access this Page | <a href='./adminlogin.php'>Login</a>        
    </body>
</html>
  • 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-16T15:13:59+00:00Added an answer on June 16, 2026 at 3:13 pm

    Scenario 1 : when span is in <Head> tag

    You have to use CDATAlike below.

    <script type="text/javascript">
    //<![CDATA[
    ...code...
    //]]>
    </script>
    

    Check for more information When is a CDATA section necessary within a script tag?

    Scenario 2: when span is in <Body> tag

    <body>
       <div></div>
    
    <script>
       $("div").html("<span class='red'>Hello <b>Again</b></span>");
    </script>
    
    </body>
    

    EDIT

    Your problem may be this:you have to put errorflag for msg

    Your code (wrong)

    if(result.errorflag){
    
               //do your stuff on getting error message
              var newHtml="<span class='red'>"+result.msg+"</span>"; 
              $("#targetdiv").html(newHtml);  //i am displaying the error msg here
    

    Corrected one:

     if(result.errorflag){
    
                   //do your stuff on getting error message
                  var newHtml="<span class='red'>"+result.errorflag+"</span>"; 
                  $("#targetdiv").html(newHtml);  //i am displaying the error msg here
    

    I hope this will help you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have this anonymous function in our code, which is part of the jQuery's
I have jQuery code like this workig fine in FF, but totally fails in
I have this jQuery code from my previous project and I want to modify
I have this code: var mods1 = ['a', 'b', 'c', 'd']; var mods2 =
I am trying to understand this line of code. it's from the blueimp jquery
I have this code This is the script in my head <script src=jquery.js></script> <script
Here's part of my code for a jQuery word counter. My question is: how
I'd expect a right-click-context-menu-style pop-up menu to be a part of jQuery UI. But
I'm loading part of my webpage using AJAX, in particular jQuery.load() . With this
This is a two-part question. I'm using jQuery for a project and wanting to

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.