Lucio Carrera
Lucio Carrera

Reputation: 31

Response for preflight is invalid (redirect), browser keep using OPTION method

so im trying to do this:

if (userPass == "0" && emailPass == "0" && dniPass == "0"){

        $.ajax({
            method: "POST",
            contentType: "text/plain",
            dataType : "text",
            url: "..php/newUser.php",
            data: { uid: uId, Plan : plan, Name : name, Dni : dni, Email : email, User : user, Pass : pass},
            success: doneReg

        });

    }
}

But i keep getting "Response for preflight is invalid (redirect)" although im making the request to my own server. The browser keeps using the OPTIONS method.

I looked in google and everywhere they said it was a CORS problem that was solved by indicating that the content-type was text / plain but as you can see in the code I'm trying to do that but it does not work. Does anyone know how to fix it?

doneReg is the callback to get the data.

newUser.php respones is just a plain text.

The data is just Strings.

Upvotes: 1

Views: 71

Answers (1)

skyboyer
skyboyer

Reputation: 23685

background: your backend must not answer with redirect to OPTIONS request.

Possible root cause:

  1. you are requesting wrong URL. Open Developer Tools in your browser and check actual URL is requesting(you can see it at Network tab).
  2. your backend is configured in wrong way(then you should get the same error in other cases)

Upvotes: 1

Related Questions