In order to provide consistent chaining from the returned promise of the core $.SPServices function, I had to implement the always() method instead of the $.ajax complete() method.
Here is the patched code.
```
// Finally, make the Ajax call
promisesCache[msg] = $.ajax({
// The relative URL for the AJAX call
url: ajaxURL,
// By default, the AJAX calls are asynchronous. You can specify false to require a synchronous call.
async: opt.async,
// Before sending the msg, need to send the request header
beforeSend: function (xhr) {
// If we need to pass the SOAPAction, do so
if(WSops[opt.operation][1]) {
xhr.setRequestHeader("SOAPAction", SOAPAction);
}
},
// Always a POST
type: "POST",
// Here is the SOAP request we've built above
data: msg,
// We're getting XML; tell jQuery so that it doesn't need to do a best guess
dataType: "xml",
// and this is its content type
contentType: "text/xml;charset='utf-8'",
/*
complete: function(xData, Status) {
// When the call is complete, call the completefunc if there is one
if($.isFunction(opt.completefunc)) {
opt.completefunc(xData, Status);
}
}
*/
}).always(function (data, Status, xData) {
// When the call is complete, call the completefunc if there is one
if ($.isFunction(opt.completefunc)) {
opt.completefunc(xData, Status);
}
});
```
Comments: Ricardo, Can you open up a Discussion on this rather than an issue... its easier for the community to comment and provide feedback... I personally don't understand what issue you are trying to solve... also: .always() does not provide the same type arguments as .complete() (from the .ajax() call)... Open up a discussion and we'll exchange more info...
Here is the patched code.
```
// Finally, make the Ajax call
promisesCache[msg] = $.ajax({
// The relative URL for the AJAX call
url: ajaxURL,
// By default, the AJAX calls are asynchronous. You can specify false to require a synchronous call.
async: opt.async,
// Before sending the msg, need to send the request header
beforeSend: function (xhr) {
// If we need to pass the SOAPAction, do so
if(WSops[opt.operation][1]) {
xhr.setRequestHeader("SOAPAction", SOAPAction);
}
},
// Always a POST
type: "POST",
// Here is the SOAP request we've built above
data: msg,
// We're getting XML; tell jQuery so that it doesn't need to do a best guess
dataType: "xml",
// and this is its content type
contentType: "text/xml;charset='utf-8'",
/*
complete: function(xData, Status) {
// When the call is complete, call the completefunc if there is one
if($.isFunction(opt.completefunc)) {
opt.completefunc(xData, Status);
}
}
*/
}).always(function (data, Status, xData) {
// When the call is complete, call the completefunc if there is one
if ($.isFunction(opt.completefunc)) {
opt.completefunc(xData, Status);
}
});
```
Comments: Ricardo, Can you open up a Discussion on this rather than an issue... its easier for the community to comment and provide feedback... I personally don't understand what issue you are trying to solve... also: .always() does not provide the same type arguments as .complete() (from the .ajax() call)... Open up a discussion and we'll exchange more info...