Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2591

zk.loadScript() can check file existence

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Normal
    • Resolution: Won't Fix
    • Affects Version/s: 7.0.4
    • Fix Version/s: 8.0.0
    • Component/s: None
    • Security Level: Jimmy
    • Labels:
      None
    • gh.sprint.customfield.default.name:
      ZK 8.0.1

      Description

      Requirement Description

      When we load an external script like
      zk.loadScript('http://ende.de/test.js', 'myscript');

      It might fail to load the external script. In such case, the whole application will halt on Processing message and go timeout with the message:
      Error code 1: ZK error, before mounting. ...

      Although users can see an error message in developer tool. Maybe ZK can check a script's existence before loading.

      Current Workaround

      Check before loading like:
      http://www.kirupa.com/html5/checking_if_a_file_exists.htm
      http://stackoverflow.com/questions/3646914/how-do-i-check-if-file-exists-in-jquery-or-javascript

      Proposed solution

      allow to pass a callback function. ZK calls the callback function after loading is done and pass the loading status no matter succeed or fail.

        Activity

        Hide
        ChunfuChang ChunfuChang added a comment -

        Please apply jQuery.ajax to accomplish the purpose.
        Example:

        var url = 'http://ende.de/test.js';
        jq.ajax({
            url: url,
            error: function() {
                 console.log('script not exists');
             },
            success: function() {
               	 zk.loadScript(url);
             }
        });
        
        Show
        ChunfuChang ChunfuChang added a comment - Please apply jQuery.ajax to accomplish the purpose. Example: var url = 'http://ende.de/test.js'; jq.ajax({ url: url, error: function () { console.log('script not exists'); }, success: function () { zk.loadScript(url); } });

          People

          • Assignee:
            ChunfuChang ChunfuChang
            Reporter:
            hawk hawk
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 3 hours
              3h

                Agile