Dropzonejs: how to fix error “Server responded with 0 code”

Server responded with 0 code

<form action="http://cdn.tutorialspots.com/ajax.php?action=uploadimage" method="POST" enctype="multipart/form-data" class="dropzone needsclick dz-clickable dz-started" id="demo-upload">

We upload to other domain (cdn.tutorialspots.com), we see a request with method OPTIONS

options request

We see a request header:

Access-Control-Request-Headers: cache-control,x-requested-with

and don’t see response header Access-Control-Allow-Headers

This is the reason why we get this error.

Code to fix this error:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS'); 

    header('Access-Control-Allow-Headers: '
} else {
    header('Access-Control-Allow-Headers: origin, x-requested-with, content-type, cache-control');


Recent search terms:

  • removejj2

Leave a Reply