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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:28:14+00:00 2026-05-29T05:28:14+00:00

In an earlier post today the answer has led me down the route of

  • 0

In an earlier post today the answer has led me down the route of using a JSON feed to populate elements in my page.

Something new to learn!!

the JSON data is created from a PHP script which retrieves the data from a Mysql database. The php script retrieves a specific record which I need to pass to the php script with the getJson call.

I’ve had success with creating the url with the parameters added as a GET method but I can’t find an example of a POST method – the parameters should go as an optional parameter. here’s what I have so far…

function loadData(index) {
        alert(index);//debug
            $.getJSON('loadJSONholeData.php' , 
                {hole: index} ,
                function(data) {

I’ve found examples for a twitter feed which shows a parameter like option: “cat”, but can’t find an option where the value is in a variable.

I don’t understand how to use the parameters – where am I going wrong. Appreciate this is probably a fundamental issue but I’m learning.

Thanks

Update:
I’ve revised the code per the responses below and used both suggestions to pass the POST parameter, but the receiving PHP code is not reading the POST parameter and just returns the default query values.

I even used as static value of 1 both as a value and as a string but no joy.

Here’s my receiving PHP code which accesses the POST values:

$hole = 3;
if (isset($_POST['hole'])) {
$hole = $_POST['hole'];
}

I’m missing something basic here. The value in ‘index’ definitely exists as it shows in the debug and JSON data is being returned )(but the default). I can go back to my GET method but want to see this work!!

Thanks

Update: Success!!

I played around further with the revised code. I removed the content type parameter from the code and it all works now, the PHP is returning the correct query.

I assume then that by specifying the JSON type in contentType it passes the POST parameter in a different way to PHP which expects it in anpther way?

Onwards and upwards – thanks

  • 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-29T05:28:15+00:00Added an answer on May 29, 2026 at 5:28 am

    The $.getJSON() method does an HTTP GET and not POST. Try something like this –

     $.ajax({
                url: 'loadJSONholeData.php',
                data: JSON.stringify({hole: index }),          
                type: 'POST',
                contentType: 'application/json;',
                dataType: 'json',
                success: function (result) {
                //(result.d) has your data.
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on one answer to an earlier post , I'm investigating the possibility of
I posted earlier today about an error I was getting with using the predict
As I mentioned in an earlier post, I will be using flot for an
Earlier today I posted another post where @Darin Dimitrov helped me great, however once
As I discussed with Inerdia on the earlier post , something is still strange
I saw a post earlier today and have been playing around with: http://arashkarimzadeh.com/index.php/jquery/7-editable-jquery-plugin.html What
From an earlier post about trying to improve my sites performance I have been
Apologies if this seems like a duplicate post... Thomas Warner kindly answeres an earlier
This question is related with one of my earlier questions.. Previous Post In there
Earlier today a question was asked regarding input validation strategies in web apps .

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.