Use jquery ajax rather than d3

This commit is contained in:
Nick O'Leary 2014-11-12 11:30:30 +00:00
parent 42cd6f94a7
commit 66005a2688
1 changed files with 74 additions and 72 deletions

View File

@ -477,22 +477,24 @@
var label = (this.name||this.payload).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"); var label = (this.name||this.payload).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
if (this.payloadType === "date") { label = "timestamp"; } if (this.payloadType === "date") { label = "timestamp"; }
if (this.payloadType === "none") { label = "blank"; } if (this.payloadType === "none") { label = "blank"; }
d3.xhr("inject/"+this.id).post(function(err,resp) {
if (err) { $.ajax({
if (err.status == 404) { url: "inject/"+this.id,
RED.notify("<strong>Error</strong>: inject node not deployed","error"); type:"POST",
} else if (err.status == 500) { success: function(resp) {
RED.notify("<strong>Error</strong>: inject failed, see log for details.","error"); RED.notify("Successfully injected: "+label,"success");
} else if (err.status == 0) { },
RED.notify("<strong>Error</strong>: no response from server","error"); error: function(jqXHR,textStatus,errorThrown) {
} else { if (jqXHR.status == 404) {
RED.notify("<strong>Error</strong>: unexpected error: ("+err.status+")"+err.response,"error"); RED.notify("<strong>Error</strong>: inject node not deployed","error");
} } else if (jqXHR.status == 500) {
} else if (resp.status == 200) { RED.notify("<strong>Error</strong>: inject failed, see log for details.","error");
RED.notify("Successfully injected: "+label,"success"); } else if (jqXHR.status == 0) {
RED.notify("<strong>Error</strong>: no response from server","error");
} else { } else {
RED.notify("<strong>Error</strong>: unexpected response: ("+resp.status+") "+resp.response,"error"); RED.notify("<strong>Error</strong>: unexpected error: ("+jqXHR.status+")"+textStatus,"error");
} }
}
}); });
} }
} }