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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:46:25+00:00 2026-05-29T04:46:25+00:00

I am trying to POST a raw string via jQuery.ajax() e.g., contact_list=352345 I have

  • 0

I am trying to POST a raw string via jQuery.ajax()

e.g.,

contact_list=352345

I have

$.ajax({
        beforeSend: function(xhr){
            xhr.setRequestHeader('Content-Type', header);
        }
        },
        url: link,
        type: type,
        processData:false,
        data: data,
        success: function(data){
            console.log(data);
        }
     });

Most of the time I am sending JSON data, so header='application/json'

On the server side, I echo $HTTP_RAW_POST_DATA and see my JSON string just fine.

However, I sometimes want to send normal form data too. But when I set header='application/x-www-form-urlencoded' $HTTP_RAW_POST_DATA is empty.

ProcessData is false, so shouldn’t it just pass my string on through?

As a temporary workaround I’m just leaving the header as application/json and ignoring the Content-Type on the server for this particular endpoint.

  • 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-29T04:46:28+00:00Added an answer on May 29, 2026 at 4:46 am

    PHP $HTTP_RAW_POST_DATA is not available with enctype=”multipart/form-data”. http://www.php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data

    So, now on the server I do the following:

    if (count($_POST == 0){
        $raw = file_get_contents('php://input');    
    }else{
        $raw = '';
        foreach($_POST as $key => $value) {
            $raw = $raw.$key.'='.$value.'&';
        }
    }
    

    Seems to be working.

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

Sidebar

Related Questions

I'm trying to POST a http request using ajax, but getting a response from
So i'm trying to POST something to a webserver. System.Net.HttpWebRequest EventReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(url); System.String
I'm trying to post a JavaScript data object with the following: $.post(frm.attr(action), data, function(res)
I'm currently trying to do the same function the Ajax.BeginForm helper does but instead
I'm trying post a javascript array using jquery $.post method to php and use
I'm trying to get page data using cURL and sending variables via POST. Here's
I am trying to sending XML content through POST to a controller ('Parse') method
I'm trying to do a raw POST to an internal page from a unit
I'm using Json.NET to deserialize a jQuery.post() JSON param. The raw value that's posted
I have two systems I'm trying to integrate. One is built on raw servlets,

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.