dourao1877 2013-09-17 15:44
浏览 305

XMLHttpRequest上的405错误

Here's my code:

var formData = new FormData();
        for (var i = 0; i < ctx.fileData.length; i++) {
          formData.append('file', ctx.fileData[i]);
        }

        // now post a new XHR request
        var xhr = new XMLHttpRequest();
        xhr.open('POST', '/site-manager-gateway/add-content');
        xhr.onload = function () {
          if (xhr.status === 200) {
            console.log('all done: ' + xhr.status);
          } else {
            console.log('Something went terribly wrong...');
          }
        };

        xhr.send(formData);

I get an error:

POST http://dev-site.net/site-manager-gateway/add-content 405 (Method Not Allowed) 

But I'm posting to the same domain.

Where am I going wrong?

EDIT, PHP file (site-manager-gateway):

public function addContent()
{
    var_dump('a');
    die();
}
  • 写回答

0条回答 默认 最新

    报告相同问题?