POST JSON data to file return 501 Unsupported

By : Hugo

I'm following along the ReactJS tutorial for creating a Comments section (found here).

Everything seems to be working fine except for creating new comments. When I send the POST request by submitting the new comment, the server (Python's SimpleHTTPServer) returns 501: Unsupported method ('POST')

Here is the ajax call:

handleCommentSubmit: function(comment) {
    url: this.props.url,
    dataType: 'json',
    type: 'POST',
    data: JSON.stringify(comment),
    success: function(data) {
      console.log("Successful POST to" + this.props.url);
      this.setState({data: data});
    error: function(xhr, status, err) {
      console.error(this.props.url, status, err.toString());

I've been debugging the app for a while and I know the handler is getting called. Firefox's console prints the error message and I've stepped through it with the debugger.

By : Hugo

This video can help you solving your question :)
By: admin