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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T09:02:16+00:00 2026-05-16T09:02:16+00:00

Here is my jQuery code: <script type=text/javascript> //<!– $(document).ready(function() { $(‘input[type=submit]’).click(function() { $.ajax({ type:

  • 0

Here is my jQuery code:

<script type="text/javascript">
    //<!--
$(document).ready(function() {

    $('input[type="submit"]').click(function() {
        $.ajax({
              type: 'POST',
              url: $('form').attr('action'),
              success: function(data) {
                  //
              }
        });
        return false;
    });

});    //-->
</script>

What I want to do after the submit button is clicked is:

  • make an AJAX request to the page identified by form’s action attribute (which happens to be the same php script with the form… so basically the form should submit to the same page).
  • replace the HTML of the whole page with the ajax request returned value.

However, I don’t know how to do that. There is no html or body tag on the page with the form as the form is getting icnluded in another page with jQuery.

So how to replace the HTML of the page with the HTML ajax returns?

This is how the whole HTML looks like (this is evrything, there is no html or body tag):

<form enctype="application/x-www-form-urlencoded" method="post" action="editDocumentQuestion.php?iqid=-5">
    <dl>
        <dt>
            <label for="questionBody">Otázka:</label>
        </dt>
        <dd style="margin-left: 0;">
            <textarea name="questionBody" id="questionBody" rows="4" cols="95" style="border: 1px solid #2278B9; font-family: sans-serif;">Otazka</textarea>

        </dd>
        <dt style="padding-top: 1em;">
            <label for="questionCorrectAnswer">Odpovede:</label>
        </dt>
        <dd style="margin-left: 0;">
            <div class="pad-top">
                <div style="margin-right: 1em; float: left;"><input type="radio" name="questionCorrectAnswer" class="questionCorrectAnswer" value="1" checked="checked" />a)</div>
                <div style="float: left;"><textarea name="questionAnswer1" id="questionAnswer1" rows="2" cols="88" style="border: 1px solid #2278B9; font-family: sans-serif;">Odpoved a</textarea></div>

                <div style="clear: both; height: 0; line-height: 0;"></div>
            </div>
            <div class="pad-top">
                <div style="margin-right: 1em; float: left;"><input type="radio" name="questionCorrectAnswer" class="questionCorrectAnswer" value="2" />b)</div>
                <div style="float: left;"><textarea name="questionAnswer2" id="questionAnswer2" rows="2" cols="88" style="border: 1px solid #2278B9; font-family: sans-serif;">Odpoved b</textarea></div>
                <div style="clear: both; height: 0; line-height: 0;"></div>
            </div>
            <div class="pad-top">

                <div style="margin-right: 1em; float: left;"><input type="radio" name="questionCorrectAnswer" class="questionCorrectAnswer" value="3" />c)</div>
                <div style="float: left;"><textarea name="questionAnswer3" id="questionAnswer3" rows="2" cols="88" style="border: 1px solid #2278B9; font-family: sans-serif;">Odpoved c</textarea></div>
                <div style="clear: both; height: 0; line-height: 0;"></div>
            </div>
        </dd>               
        <dt>
            &nbsp;
        </dt>

        <dd style="margin-left: 24.5em;">
            <input type="submit" name="editovatDokumentovuOtazku" id="editovatDokumentovuOtazku" value="Ulož" style="width: 6em; padding: .3em 0;" />
        </dd>
    </dl>
</form>

<script type="text/javascript">
    //<!--
$(document).ready(function() {

    $('input[type="submit"]').click(function() {
        $.ajax({
              type: 'POST',
              url: $('form').attr('action'),
              success: function(data) {
                  //
              }
        });
        return false;
    });

});    //-->
</script>  
  • 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-05-16T09:02:17+00:00Added an answer on May 16, 2026 at 9:02 am

    Even though there is no body or html tag you should be able to replace it like this:

    <script type="text/javascript">
        //<!--
    $(document).ready(function() {
    
        $('input[type="submit"]').click(function() {
            $.ajax({
                  type: 'POST',
                  url: $('form').attr('action'),
                  success: function(data) {
                      $('body').html(data);
                  }
            });
            return false;
        });
    
    });    //-->
    </script>
    

    Firefox 3.6.8, IE 8 and Chrome automatically inserts html and body tags if they are not present (those are the ones I have tested against)

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

Sidebar

Related Questions

Here is my test code: <script type=text/javascript> YUI({ modules: { 'jquery': { fullpath: 'script/lib/jquery.min.js'
I run this code here <html> <script type=text/javascript src=lib/jquery-ui-1.8.21.custom.min.js></script> <script src=http://127.0.0.1:5984/_utils/script/jquery.couch.js></script> <!--<script type=text/javascript src=lib/jquery-1.7.2.js></script>-->
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is my jquery code: $('input').click(function(){ $('h1').empty().queue(function(){ console.log('queue'); }); }); }); Only the first
Here is my jQuery code: $.get('/Home/GetList', function(data) { debugger; $('#myMultiSelect').val(data); }); Here is my
Here is my Jquery code: $('#unblockButton').click(function () { var blockedlist = []; var count
Here's my client-side jQuery code: $.ajaxSetup ({ contentType: application/json, datatype: 'json' }); $.ajax({ type:
Here is the html: <html xmlns=http://www.w3.org/1999/xhtml> <head> <script src=http://code.jquery.com/jquery-1.4.4.js></script> <link rel = stylesheet type
Here is my code <html xmlns=http://www.w3.org/1999/xhtml> <head runat=server> <title></title> <script type=text/javascript src=<%= ResolveUrl(Scripts/jquery-1.3.2.min.js) %>></script>
Here is jquery code which hides my table cells with the ID of .style2:

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.