Posting JSON data via AJAX

0 favourites
  • 4 posts
From the Asset Store
Forget about default textbox restrictions, you can create sprites atop of the textbox
  • I have a C# API to track leaderboard scores. It expects a json as its content-type.

    I am trying to use AJAX to POST to the scoreboard.

    I have the following events:

    When I run my layout in preview and hit these events, fiddler is showing me that the method used is OPTIONS, not POST. If I remove the Set Header event, fiddler shows me that it correctly POSTs, but is then rejected with a 415 as x-www-form-urlencoded is not an expected content-type.

    Is this a bug? Am I missing something?

  • I figured out the issues. CORS was not configured on the API to accept calls from preview.construct.net. This resulted in the the browser rejecting the OPTIONS call. Once I fixed that, construct then completed the OPTIONS call and followed it up with the POST call.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • How did you fix it on CORS?

  • I figured out the issues. CORS was not configured on the API to accept calls from preview.construct.net. This resulted in the the browser rejecting the OPTIONS call. Once I fixed that, construct then completed the OPTIONS call and followed it up with the POST call.

    Mind sharing how you configured your API to accept calls from preview.construct.net?

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