Cors request for webservice

3

I'm trying to submit a form via POST to a WebService but I'm having the following problem:

  

In 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. The response had HTTP status 404.

I have already added CORS filters to the project with WebServices .

This is my request:

$("#frmLogin").submit(function(e){
    var postData = $(this).serializeArray();
    var fUrl = $(this).attr("action");

    $.ajax({
        type: 'POST',
        url: fUrl,
        contentType: 'application/x-www-form-urlencoded',
        xhrFields:{
            withCredentials: false
        },
        crossDomain : true,
        xhrFields: {
            withCredentials: false
        },
        data: postData,
        success: function(result){
            alert('sucesso');
        },
        error: function(){
            alert('erro');
        }

    });
});

Is there something missing in it?

    
asked by anonymous 26.04.2015 / 15:36

1 answer

2

In your $ .ajax add the

headers: { 'Access-Control-Allow-Origin': '*' },
    
26.04.2015 / 23:02