[ 3 posts ]

Rahul

  • Username: rahul8590
  • Joined: Thu Mar 29, 2012 6:21 am
  • Posts: 2
  • GitHub: rahul8590
  • Gists: rahul8590
  • IRC: rahul
  • Offline
  • Profile

Unable to fetch Data using Data Source

Post Posted: Thu Mar 29, 2012 6:38 am
+0-
I have wriiten a very small snippet using DataSource Utility to fetch data from URL . The problem is everytime i try executing the script , i get failure alerts. On debugging thru chrome console , i see the data source request is not even made to the url .

The following is the code
Code:


       var myDataSource = new YAHOO.util.DataSource("http://hostname.com:8590/status?");
   myDataSource.responseType = YAHOO.util.DataSource.TYPE_TEXT;
      
        var mySuccessHandler = function() {
            alert(myDataSource);
      };
       
   var myFailureHandler = function() {
                       alert("failure");
                      alert(myDataSource);
      };
       
   var callbackObj = {
          success : mySuccessHandler,
          failure : myFailureHandler
   };

        myDataSource.sendRequest("job=1f179700-770f-11e1-9d97-458a3dcf55be",  callbackObj);





If the repose type is json and if i use type_text . Will the datasource throw an error ?
Is there any other way to fetch text from a particular url ?

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: Unable to fetch Data using Data Source

Post Posted: Thu Mar 29, 2012 8:44 am
+0-
Since you are using a full URL in the DataSource constructor, I assume your source of data lies in a different server than your pages. The browser will not allow cross-domain requests using the standard communication layer.

The response type would be relevant if you had any response, which you don't.

Rahul

  • Username: rahul8590
  • Joined: Thu Mar 29, 2012 6:21 am
  • Posts: 2
  • GitHub: rahul8590
  • Gists: rahul8590
  • IRC: rahul
  • Offline
  • Profile

Re: Unable to fetch Data using Data Source

Post Posted: Thu Mar 29, 2012 8:48 am
+0-
so how do i do cross browser request then ? Isnt there any work around for this ? or any other utilitiy apart from Data source which will allow me to do so ?
  [ 3 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum