Ich möchte den zweiten Ajaxcall als Ergebnis der Ajax-Funktion zurückgeben, kann mir jemand helfen.zurück AJAX in AJAX Anruf
private ajax(url: string, method:string, data:any = null) {
var _this = this;
return this.csrfWithoutDone().done(function (res) {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': res
}
});
return $.ajax({
url: _this.baseUrl + url,
type: method,
data: data,
});
});
}
die csrfWithoutDone Funktion:
return $.ajax({
url: _this.baseUrl + '/api/csrf',
type: 'GET'
});
BTW: dies ist in Typoskript writen aber wenn Sie mit Funktion privat ersetzen und entfernen Sie den: (Typ) funktioniert es auch in js.
Ich entferne das Angular2-Tag, da Sie jquery verwenden, um Ihre http-Aufrufe zu machen. Wenn Sie denken, dass das nicht stimmt, lassen Sie es mich wissen. – echonax
Ow yeah sure, ich habe es nur hinzugefügt, weil ich es in meinem Projekt verwende, danke, dass du mich informiert hast. – nusje2000
Vielleicht ist dies die Lösung für Ihr Problem: http://stackoverflow.com/a/22063821/4217744](http://stackoverflow.com/a/22063821/4217744) – simhumileco