1. #1
    Ext User
    Join Date
    Jul 2010
    Posts
    7
    Vote Rating
    0
    lansea is on a distinguished road

      0  

    Default How to set the jsonp request timeout?

    How to set the jsonp request timeout?


    I use Ext.util.JSONP.request() to do a cross domian json requeat, I want to know how to set the timeout, the defaule timeou is 30 sec? it is too long for me ! and I also to know how to set the timeout callback.

    thanks

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,104
    Vote Rating
    501
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Currently it's unsupported. You'd need to modify the request method so that it would run a delayed task to check if the request had succeeded by the timeout duration.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Ext User
    Join Date
    Jul 2010
    Posts
    7
    Vote Rating
    0
    lansea is on a distinguished road

      0  

    Default after timerout, how can i cancel the request?

    after timerout, how can i cancel the request?


    Quote Originally Posted by evant View Post
    Currently it's unsupported. You'd need to modify the request method so that it would run a delayed task to check if the request had succeeded by the timeout duration.
    after I chectout the request is time out, then How can I cancel the request?

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,104
    Vote Rating
    501
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You'll see it inserts a script tag, remove the script tag from the document.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Jun 2011
    Posts
    16
    Vote Rating
    0
    ITS Telco is on a distinguished road

      0  

    Default How to set the jsonp request timeout?

    How to set the jsonp request timeout?


    Hello lansea,

    I solve the problem on this way.
    First before the request start I set a timer:

    alertTimerId = window.setTimeout("timeout_req()", 5000); // for 5 sec

    In the function timeout_req I call the callback manually:

    Ext.util.JSONP.callback({'error':'timeout'});

    For my issue it seems it works. Maybe it is a help for you , too.

    best regards
    Thomas

  6. #6
    Sencha User
    Join Date
    Jul 2009
    Location
    Beijing,China
    Posts
    7
    Vote Rating
    0
    wuyahuang is on a distinguished road

      0  

    Default


    Hello ITS Telco.
    I use you code.
    But Google Chrome show an error
    "Uncaught TypeError: Cannot read property 'callback' of null"
    and I also found out the method callback() in the file Ext.util.JSONP.js.
    how can it be?
    Thanks.


  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    16
    Vote Rating
    0
    ITS Telco is on a distinguished road

      0  

    Default Ext.util.JSONP.request and timeout

    Ext.util.JSONP.request and timeout


    Hello wuyahuang,

    it is an example for an Ext.util.JSONP.request.
    If the timer finished the timeout_req function.

    Unfortunately the Ext.util.JSONP.request do not notice this.
    So I call in the timeout_req function a callback for the Ext.util.JSONP.request.

    Of course the Ext.util.JSONP.request and the callback there must be declared.

    Hope it helps.

    best regards
    Thomas

  8. #8
    Sencha User
    Join Date
    Jul 2009
    Location
    Beijing,China
    Posts
    7
    Vote Rating
    0
    wuyahuang is on a distinguished road

      0  

    Default


    Hey Thomas.
    Thank you for you reply.But I am an newbie about sencha touch.
    I don't know how to declared function callback.
    can you tell me something about this?

    this is my code:
    timer = setTimeout("timeout_req()", 5000);
    Ext.util.JSONP.request({
    url: serverUrl,
    callbackKey: 'callback',
    scope: this,
    params: params,
    callback: function(returnObj){
    //to do
    }
    });
    function timeout_req(){
    Ext.util.JSONP.callback({'error':'timeout'});
    }

    best regards
    wuyahuang

  9. #9
    Sencha User
    Join Date
    Jul 2009
    Location
    Beijing,China
    Posts
    7
    Vote Rating
    0
    wuyahuang is on a distinguished road

      0  

    Default


    Thank you Thomas.I solve the problem.
    This is my code:

    var timeOutTimer = window.setTimeout(function (){
    console.log('time out.');
    }, 5000);
    Ext.util.JSONP.request({
    url: serverUrl,
    callbackKey: 'callback',
    scope: this,
    params: params,
    callback: ajaxRequestCallback(timeOutTimer)
    });

    function ajaxRequestCallback(timeOutTimer){
    return function(returnObj, i){
    window.clearTimeout(timeOutTimer);
    //to do
    }
    }

Similar Threads

  1. Help With JSONP Request
    By indieangler in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 7 Jul 2010, 11:03 AM
  2. Help With JSONP Request and Basics
    By indieangler in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 6 Jul 2010, 1:46 PM
  3. Feature request - timeout for treeloader
    By zombeerose in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 10 Jun 2009, 3:42 PM
  4. Ajax request timeout?
    By eyp in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 26 Nov 2007, 7:33 AM

Thread Participants: 3

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar