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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:23:56+00:00 2026-06-14T17:23:56+00:00

i am trying to get my ajax/json script to work, i have looked over

  • 0

i am trying to get my ajax/json script to work, i have looked over stackoverflow, but can’t find anything that looks like it would help. Basically all i am trying to do is when a user clicks on a submit button, for a hidden input value to be sent to another php script via ajax, where it will be changed etc… then sent back via ajax and displayed inside a div through a responce, i am not sure what i am doing wrong.

At the moment i am getting nothing, no output or anything.

I will try and be as thorough as possible in the code i give below, thanks for all the help.

AJAX script on main page

<script>
$(document).ready(function () {
  $(".add_detail_land_down").click(function () {
    var hidden_count = $('input[name=addon_detail_hidden_count]').val();
    $.ajax({
      type: "GET",
      url: "ajax_script.php",
      data: {
        hidden_count: hidden_count
      },
      dataType: "json",
      statusCode: {
        success: function (data) {
          $("#total_hidden").html(data.total_hidden);
        }
      }
    });
  })
});
$(".add_detail_land_down").click();
</script>

The form head on main page (thought i might as well add it, just incase)

<form action="" method="post">

The hidden input on main page

<input type="hidden" name="addon_detail_hidden_count" id="addon_detail_hidden_count" class="addon_detail_hidden_count" value="1" />

The submit button for starting the ajax process on main page

<input name="add_detail_land_down" type="submit" class="add_detail_land_down" value="add_detail_down"/>

The code in ajax_script.php

    <?php 

$hidden_count = $_GET["hidden_count"];

$hidden_count = $hidden_count + 1;
include 'connect_to_mysql.php';

echo json_encode(array("total_hidden" => $hidden_count ));

 ?>

Thanks for any and all help

  • 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-14T17:23:57+00:00Added an answer on June 14, 2026 at 5:23 pm

    Amongst all the other problems mentioned: statusCode/success syntax problem , and the click trigegr outlsde of document.ready you also need to prevent the browser default submittal of the form.

    Currently your page is likely refreshing when you submit… normal browser behavior.

    In the click handler you need to prevent this by either returning false or using preventDefault()

    $(".add_detail_land_down").click(function (event) {
    
       /* use either of these */
    
       /* before your ajax code */
        event.preventDefault();
    
        /* or after your ajax code*/
    
         return false;
    
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a JSON from a webservice with javascript $.Ajax call. <script
I've been trying to get a script to work that calls a PHP file
I'm trying to get a nested form to submit via AJAX, but I can't
While trying to GET a JSON, my callback function is NOT firing. $.ajax({ type:GET,
I have been trying to get a jquery ajax function to return data from
I'm new to JSON and not that familiar with jQuery. I have been trying
I am trying to get some data from an API that provides JSON responses.
I have a bit of jquery that makes an ajax request to a script
I'm trying to get JSON data from a website using the following code, but
I'm trying to get a JSON input with AJAX and load it in a

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.