Loading ...
Sorry, an error occurred while loading the content.
 

Re: [JavaScript] is there any way to identify that no response has been returned in ajax callback

Expand Messages
  • mahesh chelluboina
    Hi ,   If there is no repsonse or value . in the call back method you can put an if condition as   if(response.value){ do bussinesslogic} else{   do error
    Message 1 of 5 , Aug 18, 2009
      Hi ,
       
      If there is no repsonse or value . in the call back method you can put an if condition as
       
      if(response.value){
      do bussinesslogic}
      else{
       
      do error control logic
      }
       
      value is not returned then you can tackle in the else condition
       
      Regards,
      Mahesh
       


      --- On Tue, 18/8/09, Nikeeta Vanjara <Nikeeta.Vanjara@...> wrote:


      From: Nikeeta Vanjara <Nikeeta.Vanjara@...>
      Subject: [JavaScript] is there any way to identify that no response has been returned in ajax callback
      To: JavaScript_Official@yahoogroups.com
      Date: Tuesday, 18 August, 2009, 9:40 AM


       



      Hello,

      i have problem, while using ajax , we get its response in its call back method, if there is response then i can get its length like

      for eg.
      function getsomething_ CallBack( response)
      {

      var ds = response.value;
      alert(ds.Tables[ 0].Rows.length) ;
      }

      bur if database does not return any value then i can not get any prompt or some "undefined" kind of message, not even any javascript error,

      hence is there any way to identify that no response has been returned in ajax callback method ?

      thank u...

















      Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com

      [Non-text portions of this message have been removed]
    • janwen
      ... that is easy to do that,do like this: if response is plain text if(xmlHttpRequest.responseText != null){ } if response is xml document like this:
      Message 2 of 5 , Aug 19, 2009
        Bipool wrote:
        >
        >
        > You can check following way
        > unction getsomething_CallBack(response)
        > {
        > if(response)
        > {
        > var ds = response.value;
        > if(ds)alert(ds.Tables[0].Rows.length);
        > }
        > }
        >
        > On Tue, Aug 18, 2009 at 10:10 AM, Nikeeta Vanjara
        > <Nikeeta.Vanjara@... <mailto:Nikeeta.Vanjara%40gmail.com>
        > > wrote:
        >
        > >
        > >
        > > Hello,
        > >
        > > i have problem, while using ajax , we get its response in its call back
        > > method, if there is response then i can get its length like
        > >
        > > for eg.
        > > function getsomething_CallBack(response)
        > > {
        > >
        > > var ds = response.value;
        > > alert(ds.Tables[0].Rows.length);
        > > }
        > >
        > > bur if database does not return any value then i can not get any
        > prompt or
        > > some "undefined" kind of message, not even any javascript error,
        > >
        > > hence is there any way to identify that no response has been returned in
        > > ajax callback method ?
        > >
        > > thank u...
        > >
        > >
        > >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        that is easy to do that,do like this:
        if response is plain text
        if(xmlHttpRequest.responseText != null){
        }

        if response is xml document like this:
        if(xmlHttpRequest.responseXML != null){
        }


        [Non-text portions of this message have been removed]
      • Nikeeta Vanjara
        Thanks a lot mahesh and bipool, but that problem has been re-solved , actully it was not problem, it was a codding misake, if it we pass some input then only
        Message 3 of 5 , Aug 20, 2009
          Thanks a lot mahesh and bipool,
          but that problem has been re-solved , actully it was not problem, it was a
          codding misake, if it we pass some input then only that method was getting
          called (there was if condition) hence then only i was getting some value in
          response, hence have added validation to pass atleast input to get response
          on button click,

          if(response) was working but response.value was giving javascript error
          saying object does not support this property

          thank u once again...


          On 8/19/09, mahesh chelluboina <mahesh_409@...> wrote:
          >
          >
          >
          > Hi ,
          >
          > If there is no repsonse or value . in the call back method you can put an
          > if condition as
          >
          > if(response.value){
          > do bussinesslogic}
          > else{
          >
          > do error control logic
          > }
          >
          > value is not returned then you can tackle in the else condition
          >
          > Regards,
          > Mahesh
          >
          >
          > --- On Tue, 18/8/09, Nikeeta Vanjara <Nikeeta.Vanjara@...<Nikeeta.Vanjara%40Gmail.com>>
          > wrote:
          >
          > From: Nikeeta Vanjara <Nikeeta.Vanjara@...<Nikeeta.Vanjara%40Gmail.com>
          > >
          > Subject: [JavaScript] is there any way to identify that no response has
          > been returned in ajax callback
          > To: JavaScript_Official@yahoogroups.com<JavaScript_Official%40yahoogroups.com>
          > Date: Tuesday, 18 August, 2009, 9:40 AM
          >
          >
          >
          > Hello,
          >
          > i have problem, while using ajax , we get its response in its call back
          > method, if there is response then i can get its length like
          >
          > for eg.
          > function getsomething_ CallBack( response)
          > {
          >
          > var ds = response.value;
          > alert(ds.Tables[ 0].Rows.length) ;
          > }
          >
          > bur if database does not return any value then i can not get any prompt or
          > some "undefined" kind of message, not even any javascript error,
          >
          > hence is there any way to identify that no response has been returned in
          > ajax callback method ?
          >
          > thank u...
          >
          > Love Cricket? Check out live scores, photos, video highlights and more.
          > Click here http://cricket.yahoo.com
          >
          > [Non-text portions of this message have been removed]
          >
          >
          >


          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.