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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:56:47+00:00 2026-06-13T16:56:47+00:00

I am trying to use ajax to navigate to a php script in the

  • 0

I am trying to use ajax to navigate to a php script in the background so that it performs some commands but the problem is that it is not performing the commands, which tells me that my ajax is either incorrect or I am incorrectly doing something that it is not calling the ajax. Can yo please look at the code and state what I am doing wrong? I known the php script is suppose to navigate to insertQuestion.php does work because if I navigate to that page using the form action, then it performs the commands in that script, but when I try and use ajax to navigate to the script in the background, it just doesn’t do it:

Code:

<form id="QandA" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" onsubmit="return myClickHandler()">

....

</form>

 function myClickHandler()
    {
        if (!validation())
            return false;

        if (!confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards Questions, Options and Answers for your Assessment." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" ))
            return false;

        $.ajax({
            url: "insertQuestion.php",
            data: $("#QandA").serialize(),
            async: false
        });

        return true;
    }

UPDATE:

It is still not navigating to the insertQuestion.php page, also the problem now is that it is not checking for validation and not displaying confirm box in javascript function. Below I have included an update on what current code now looks like:

<form id="QandA" action="<?php echo htmlentities($action); ?>" method="post" onsubmit="return myClickHandler(); return false;">

....

</form>

         <script type="text/javascript">

    function myClickHandler()
    {
        if (!validation())
            return false;

        if (!confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards Questions, Options and Answers for your Assessment." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" ))
            return false;

       $.ajax({
            url: "insertQuestion.php",
            data: $("#QandA").serialize(),
            async: false
            type: "POST"
        });

        return true;
    }

</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-06-13T16:56:48+00:00Added an answer on June 13, 2026 at 4:56 pm

    use type: “POST” because

    type String Default: ‘GET’ The type of request to make (“POST” or
    “GET”), default is “GET”. Note: Other HTTP request methods, such as
    PUT and DELETE, can also be used here, but they are not supported by
    all browsers.

    .ajax

    $.ajax({
                url: "insertQuestion.php",
                data: $("#QandA").serialize(),
                async: false,
                type: "POST"
            });
    

    about submit :
    HTML:

    <form id="QandA">
    ...
    </form>
    

    JS:

    $(function() {
    myClickHandler=function(e)
        {
            if (!validation())
                return false;
    
            if (!confirm("Make sure that your details are correct, once you proceed after this stage you would not be able to go back and change any details towards Questions, Options and Answers for your Assessment." + "\n" + "\n" + "Are you sure you want to Proceed?" + "\n" ))
                return false;
    
            $.ajax({
                url: "insertQuestion.php",
                data: $("#QandA").serialize(),
                async: false,
                type: "POST"
            });
    
            return true;
        };
    
    
    
    $('#QandA').submit(myClickHandler);
    
    
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Ajax to call a PHP script to write to two
I am trying to use AJAX to populate some select boxes that were auto-generated
I'm trying to use AJAX via jquery with ASP.NET MVC, but I'm not able
Im trying to use AJAX inside a live()-function but it does not work. Any
I am trying to use AJAX for a web app game that im making.
I am running into a problem trying to use AJAX and jQuery with ASP.NET
I am trying to use Liftscreen to implement a form in ajax but I
I'm trying to use Ajax in CakePHP, and not really getting anywhere! I have
I'm trying to use some AJAX and ASP.Net together to enable me to run
I'm trying to use an AJAX request to load some information into a table

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.