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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:36:33+00:00 2026-06-12T00:36:33+00:00

My AJAX request to pings the server, and the URL but returns an error

  • 0

My AJAX request to pings the server, and the URL but returns an error because it doesnt like the ‘<‘ as the open tag for the php script.

AJAX script.

 $.ajax({
url: "data.php",
type: "POST",
data: JSON.stringify({"data":transaction}),
dataType: "json",
success: function(data, textStatus, jqXHR){
    alert("success");
    currentProcesses -= 1;
    $("<span>").html("Ajax Call Complete.  Releasing lock for process").appendTo($(body));
},
error: function(jqXHR, textStatus, errorThrown){
    alert("error with ajax call "+textStatus+" "+errorThrown);
}
 });

php script

 <?php
   $win = $_POST['data'];
 ?>

Am I using the wrong flag settings for the AJAX call?

  • 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-12T00:36:34+00:00Added an answer on June 12, 2026 at 12:36 am

    The body of your POST request is encoded as application/json instead of application/x-www-form-urlencoded.

    You aren’t doing anything to make the request say that the data is encoded in JSON and you aren’t doing anything in PHP to try to parse JSON.

    As a result, PHP fails to populate $_POST, because the data is in the wrong format.

    The solution is: Don’t send JSON. Just give the data property an object as its value, and jQuery will serialise it to application/x-www-form-urlencoded data for you.

    data:  { "data": transaction },
    

    (Assuming that transaction is not a complex data type (like an array or object).

    Additionally, the body variable is undefined. You should either use a string (to make it a selector: "body") or pass the body element directly: document.body.

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

Sidebar

Related Questions

I make an AJAX request like so using JQuery: $.ajax({ type: GET, url: getvideo.php,
I make an AJAX request to a PHP script which returns a number from
Im doing a simple ajax request like:` $.ajax({ type: 'POST', url: 'http://' + serverIP
I am executing an AJAX request using jQuery as such: $.get({ url: 'run_program.php', data:
I'm doing an ajax request through jQuery and for example, my URL is http://test.com/query.php?hello=foo
I am making an AJAX request to a .aspx script & it returns HTML.
When i do an ajax request i go to a php script which does
I'm making a AJAX request with jquery like: $.get('/Stuff.php', function (data) { $('#own').html(data); });
I have a jquery ajax request as follows; $.ajax({ type: 'POST', url: 'ajax.php', dataType:
My jsonp ajax request looks like this, but its not working. My guess is

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.