BackboneJS - set http headers

Use the following code to set http headers with backbone's save, fetch and destroy methods.

model.save({ }, {beforeSend: sendHeader,
                                        success : function(data) {
                                             alert("success"); 
                                        },
                                        error : function(m, xhr, o) {
                                             alert("error");  
                                        }
                                });

sendHeader : function(xhr) {
                        xhr.setRequestHeader("name", "tdd");
                }

Technology: 

Search