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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:42:56+00:00 2026-06-05T23:42:56+00:00

I’m having trouble getting the server to recognize a JSON POST request since I

  • 0

I’m having trouble getting the server to recognize a JSON POST request since I changed the code a bit. Previously, a POST request was made for each iteration of a for loop, but now I’ve changed it to include a multi-level JSON array.

var json=[];

for (var i=0; i < tourList.length; i++){
  var data = tourList[i];
  json.push({latitude: data.position.ab, longitude: data.position.cb, filename: data.title, stopNum: i});
}

var results= JSON.stringify(json);
console.log(json);
console.log(results);

//this code was previously inside the for loop above, moved it outside
$.ajax({
  type: "POST",
  url: "../includes/phpscripts.php?action=postTour",
  data: results,
  datatype: "json",
  beforeSend: function(x){
    if (x && x.overrideMimeType){
      x.overrideMimeType("application/json;charset=UTF-8");
    }
  },
  success: function(data){
    if (data == "success")
      console.log("Tour update successful");
    else 
      console.log("Tour update failed");
  }
});

At this point in time, tourList has a length of 6 and results is based on Google Maps marker clicks and produces this in Firebug:

[
  {"latitude":43.682211,"longitude":-70.45070499999997,"filename":"../panos/photos/1-prefix_blended_fused.jpg","stopNum":0},
  {"latitude":43.6822,"longitude":-70.45076899999998,"filename":"../panos/photos/2-prefix_blended_fused.jpg","stopNum":1},
  {"latitude":43.682219,"longitude":-70.450828,"filename":"../panos/photos/3-prefix_blended_fused.jpg","stopNum":2},
  {"latitude":43.68218,"longitude":-70.45088699999997,"filename":"../panos/photos/4-prefix_blended_fused.jpg","stopNum":3}
]

However, nothing shows up as a $_POST variable, as $_POST shows up as type: array[0] in the debugger. So I have no data set to run json_decode upon. From what I can see, the JSON is valid. What is the issue?

  • 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-05T23:42:58+00:00Added an answer on June 5, 2026 at 11:42 pm

    Send the string as a post var.

    $.ajax({
      type: "POST",
      url: "../includes/phpscripts.php?action=postTour",
      data: {"json": results},
      dataType: "json",
      beforeSend: function(x){
        if (x && x.overrideMimeType){
          x.overrideMimeType("application/json;charset=UTF-8");
        }
      },
      success: function(data){
        if (data == "success")
          console.log("Tour update successful");
        else 
          console.log("Tour update failed");
      }
    });
    

    Access the json with $_POST["json"]

    I’m not sure what you are returning from your PHP, however, if it is json, it will never be equal to "success"

    Edit: One more issue. Your datatype parameter should be dataType, and this parameter only defines what dataType is being returned from PHP, not what you are sending it.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm trying to create an if statement in PHP that prevents a single post
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.