AJAX Plugin - "Content-Type" is overridden...or something.

0 favourites
  • 2 posts
From the Asset Store
Goodbye to sprite fonts, when you have something new on the anvil for your upcoming Games !
  • Problem Description

    The problem is with the AJAX-plugin. It seems calling "setRequestHeader" to change the "Content-Type" of the request doesn't work. It uses the default value of: "application/x-www-form-urlencoded" even if you change it to something else.

    When looking at the code in the Plugin it does indeed seems like it should work, I even printed the headers and it seemed correct.

    Steps to Reproduce Bug

    • Add AJAX object to Layout
    • In: On Layout Start, set the header: "Content-Type" to Value: "application/json"
    • Make an AJAX request to some server
    • Observe on the server that the Content-Type that is being sent is "application/x-www-form-urlencoded".

    Observed Result

    As seen above, the request header is overridden by the default one (or not being set at all)

    Expected Result

    "Content-Type" should be set to "application/json", but isn't.

    Solution

    Removing the following lines in the runtime.js of the AJAX -plugin (line 218-224), seem to fix this problem:

    if (data_)
    {
      if (request["setRequestHeader"])
      {
        request["setRequestHeader"]("Content-Type", "application/x-www-form-urlencoded");
      }
    }[/code:fsszne24]
    
    [b]Construct 2 Version ID[/b]
    Release 190 (64-bit)
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I made it disable the default application/x-www-form-urlencoded type if you use 'Set request header' to set Content-Type, so should be fixed in the next build.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)