I am attempting to set up a way of sending a json to a server which will save it to a file. I am trying to design it for a PhoneGap application.
Currently I have:
tabulated = [Some object]
$.ajax({
    url: "http://localhost:33330/write-file",
    type: "POST",
    crossDomain: true,
    data: "data=" + JSON.stringify(tabulated),
    dataType: "json",
    contentType: "application/json",
    success: function(response) {
        alert(response);
    },
    error: function(request, textStatus, errorThrown) {
        alert(request);
        alert(textStatus);
        alert(errorThrown);
    }
});
The server end is a django server. 
In urlpatterns, I included url(r'^write-file$', views.WriteToFileView.as_view()), and in the views.py, I have:
class WriteToFileView(View):                                                                                                         
    def get(self, request, *args, **kwargs):                                                                                         
        return HttpResponse()                                                                                                        
    def post(self, request, *args, **kwargs):                                                                                        
        repr(request)                                                                                                                
        return HttpResponse("Yay!") 
The response is always:
XMLHttpRequest cannot load http://localhost:33330/write-file. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:33331' is therefore not allowed access.
What am I doing wrong?
Edit 1
This was marked as a duplicate of this question, however I do not believe it is. That question is failing due to a Null Origin. I am not having this issue. The error on that page does not mention any thing about a pre-flight check, whereas mine does.
Furthermore, I am not accessing any third-party pages. I am trying to set up communication between two local host servers, on different ports. (note this in the error)  
The answers on the page mention:
- 1) "not passing jsonp type to $.get" ---> I am not using $.get, nor am I passing a jsonp
- 2) "using a file:// URL" ---> I am also not doing this.
All the same, I read through all the answers, but none of them seem to apply to my question. So can I please have an explanation on why this is a duplicate?
 
     
    