Hier ist nochmal der vollständige Header:
Request URL:https://re-manager-amit88.c9users.io/buildings/1
Request Method:POST
Status Code:404 Not Found
Remote Address:35.187.1.119:443
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
content-length:151
content-security-policy:default-src 'self'
content-type:text/html; charset=utf-8
date:Thu, 18 Jan 2018 22:45:09 GMT
vary:X-HTTP-Method-Override
X-BACKEND:apps-proxy
x-content-type-options:nosniff
x-powered-by:Express
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate, br
Accept-Language:de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:102
Content-Type:application/x-www-form-urlencoded
Cookie:c9.live.user.click-through=ok
Host:re-manager-amit88.c9users.io
Origin:https://re-manager-amit88.c9users.io
Referer:https://re-manager-amit88.c9users.io/buildings/1/edit
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Ich habe mich an dieser Anleitung orientiert.
entsprechend habe ich
//serverseitig
var methodOverride = require('method-override');
app.use(methodOverride('X-HTTP-Method-Override'));
...
app.put("/buildings/:id", function(req,res){
console.log("you got a put Method");
res.send('PUT');
});
Und mein AJAX habe ich jetzt im submit-event handler drin, aber wo ich false zurückgeben soll und was der handler für den load-event machen soll, habe ich jetzt nicht ganz verstanden. Ich habe das jetzt testweise in mein code kopiert, aber es hatte nichts in die Console geloggt.
$('document').ready(function(){
var containsID=reverseString($(location).attr('href')).split("/");
var id = containsID[1];
$("form").submit( function(event){
var xhr = new XMLHttpRequest();
xhr.open('POST', '/buildings/'+ id , true); // method-override needs it to be POST
xhr.setRequestHeader('X-HTTP-Method-Override', 'PUT');
xhr.send();
//xhr.onload = function(){
//console.log(this.status, "\n", this.response);
//};
});
});
Gruß und Dank
Uri