mardi 3 octobre 2017

how to set timeout feature in ember for AJAX call

When we call a rest service via AJAX in ember, it takes a bit of time to process the data and create a PDF and return it to the frontend side.

By the time, the server process the PDF and return back, the webpage (from where the AJAX call is triggered) times out.

Please suggest How to set timeout feature in ember for ajax?

Below is ajax code from where the URL is triggered:

actions: {
    pdfClick(bookId) {

      bookId=document.getElementById("version_"+bookId).value;
      var link1=Globals.urlPrefix + this.get('router.url') + "?pdfdownload=pdfdownload&versionId="+bookId;
      Ember.$.ajax( {
        method : 'GET',timeout:3000000,url :Globals.urlPrefix + this.get('router.url') + "/" + bookId}).then((response) => {
        var link=document.createElement('a');
        link.href=link1
        link.download="book_" + new Date() + ".pdf";
        link.click();
      });
    },




Aucun commentaire:

Enregistrer un commentaire