1
Following the code below, is there another better way to call the outgoing methodEmail() after receiving "Success" in the ajax called by the Video() method? Notice that I used callback as a solution to this problem.
Are 2 files "js":
The first file has the Windows() write method which is called by the view:
this.gravaVisita = function (visitado, visitante) { if (visitado == visitante) return; dataBD.gravaVisita(visitado, visitante, function (data) { if (data.statusRetorno == 200) dataBD.enviaEmail(); } ); }
The second is responsible for making an ajax call to the "Gravavisita" action of the "Accountmvvm" controller"
function DataBD() { this.gravaVisita = function (visitado, visitante, callback) { var dataJson = { LoginFoiVisitado: visitado, LoginVisitou: visitante }; $.ajax({ type: "POST", dataType: "json", url: "/site/apiPostForm/AccountMVVM/GravaVisita", data: dataJson, success: function (data) { if (callback) callback(data); }, error: function (error) { } }); } } var dataBD = new DataBD();