CORS POST with enyo.ajax fails on Mobile Safari 7

edited January 2014 in Enyo 2
We have a web app that makes cross-origin POST requests. On Mobile Safari 7, the requests fail; however, they work on every other platform we have tested (including Mobile Safari 5 and Safari desktop versions). The problem occurs only when using enyo.Ajax to make the requests; if we use XMLHttpRequest directly, the requests succeed. All GET requests also succeed. I've created this fiddle to demonstrate the problem. It accesses the following script at our server:


#!/usr/bin/perl -w
use strict;
use warnings;
use CGI;

my $q = CGI->new;
my %headers = map { $_ => $q->http($_) } $q->http();

print $q->header('text/plain');
print "Request method: ", $ENV{REQUEST_METHOD}, "\n";
print "Request headers:\n";
for my $header ( keys %headers ) {
print "$header: $headers{$header}\n";
The server also is configured to add the following header to replies:

Access-Control-Allow-Origin: *
We'd like to continue using enyo.Ajax for these requests, but this issue is a show-stopper. We can work around it by using plain old XMLHttpRequest objects, but a fix to Enyo (or an explanation of what we're doing wrong in our code) would sure be nice.


  • Getting the same error with Chrome 31 on iOS 7 as well, in addition to Mobile Safari 7. Will investigate some more.
  • Looks like this was related to a fix we made for iOS to prevent caching of non-cacheable requests. This fix was updated to only apply to iOS 6 in 2.3.0:

    Per the comments in the fix, you can use the header property to specify an object with cache-control: null, unless you're planning on upgrading to 2.3.0. :)
  • Thanks for this. Odd that a cache control header of no-cache would cause CORS requests to fail like that.
  • This, or a very similar issue seems to still present in 2.4.0-pre.2, 2.1, 2.1.1, etc, for me in Mobile Safari using enyo.Ajax. I wasn't able to produce this 'fix' above and am having no luck at all getting anything but an error in mobile safari.

    Is there any more information regarding this issue? or does it appear fixed for other users?

    The fiddle linked above still gives a server code of 0 using Enyo 2.2.0, however using 2.1, 2.0.1, and the nightly build all seem to work, however when I've attempted to use those older versions, i still get a 0 Server error.

    Could someone attempt to clarify this issue for me?
  • EDIT: I meant to say on ios7 not mobile safari as it throws errors in chrome on ios7 as well
  • That might still be a Safari only bug. There is no real Chrome on iOS, it is just a wrapper for UIWebView, which is just the Webkit Safari is based on.
Sign In or Register to comment.