4

I have the following javascript code...

function editShipment(){
var method = "PATCH";
var serializedData = $form.serialize();
$.ajax({
    type: "PATCH",
    url: Routing.generate('api_1_shipment_patch_shipment', {api_key: API_KEY, id:$('#caddress-shipmentID').val()}, true),
    data: serializedData,
    success: newShipmentSuccess,
    error: newShipmentError
});
}

When I run this code the Chrome developer tools "network" tab shows a patch method with data being sent to the correct URL.

however my application never receives this data.

Is it possible that the network tab is somehow wrong and that my browser isn't actually sending the data.

I'm using the latest jQuery and the receiving application is a Symfony2 web app.

Thanks in advance,

M

EDIT: It also worth noting that i have a test case passing for this patch method within my symfony codebase. so thats why I'm looking at Javascript as the culprit.

Mark Dalby
  • 61
  • 1
  • 6
  • `Is it possible that the network tab is somehow wrong` No – Satpal Jun 26 '14 at 07:44
  • Does the value of `url` have a different origin from the URL running the script? – apsillers Jun 26 '14 at 07:48
  • Does your service accepts `PATCH` requests or is limited to other http verbs? – Viktor Bahtev Jun 26 '14 at 07:52
  • @apsillers Yes it does as these are different systems - I also have post requests working perfectly fine in the same manner though and my allow origin header is set to * – Mark Dalby Jun 26 '14 at 07:56
  • @ViktorBahtev Yes - it accepts PATCH, GET and PUT – Mark Dalby Jun 26 '14 at 07:57
  • @MarkDalby Is you server sending `Access-Control-Allow-Methods: GET, POST, PATCH` in response to the [OPTIONS CORS preflight request](http://stackoverflow.com/questions/13400594/understanding-xmlhttprequest-over-cors-responsetext/13400954#13400954)? It's not necessary for GET and POST, because those are "simple" HTTP verbs, while PATCH is non-simple. – apsillers Jun 26 '14 at 08:01

0 Answers0