Pagina 2 di 2 primaprima 1 2
Visualizzazione dei risultati da 11 a 12 su 12

Hybrid View

  1. #1
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649
    questo funzionerebbe
    codice:
    $(document).ready(function() {
     $.ajax({
    	url: "http://api.flickr.com/services/feeds/photos_public.gne", 
    	dataType: "jsonp",
    	data:{
    		format:"json",
    		tags:"monkey",
    		tagmode:"any"/*,
    		jsoncallback:"processJSON" // se decommenti questo esegui processJSON come callback
    		*/
    	},
    	jsonp: "jsoncallback" ,
    	success: function(json) {
    		alert('success, check your console')
    		console.log(json)
    	},
    	error: function(request, error, tipo_errore) { alert(error+': '+ tipo_errore); }
     });
    });
    
    
    function processJSON (json) {
    	console.log(json)
    };
    quali sono le differenze?
    l' ulr che mette insieme e' praticamente
    http://api.flickr.com/services/feeds...ny&format=json
    se facessi anche solo cosi' andrebbe a buon fine
    codice:
    var script_element = document.createElement('script');
    script_element.src = 'http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=processJSON&tags=monkey&tagmode=any&format=json';
    document.getElementsByTagName('head')[0].appendChild(script_element);
    
    function processJSON (json) {
    	console.log(json)
    };
    la differenza e' che questo server e' impostato per restituire il json se viene passato un jsoncallback
    quello a cui punti tu non e' dato a noi saperlo

    ciao

  2. #2
    viiii pregooooo datemi una mano sono 5 mesi che ci provo ma non ci riesco proprio

    io devo parsare i feed di questo sito:

    http://www.emsc-csem.org/service/rss/rss.php?typ=emsc

    siccome devo leggerlo senza lato server ho usato le tecniche qui presenti:

    https://developers.google.com/feed/v1/


    ma comunque non ci riesco ! allora questo è il mio codice:



    codice:
    <script type="text/javascript">
        google.load("feeds", "1");
        function initialize() {
          var feed = new google.feeds.Feed("http://www.emsc-csem.org/service/rss/rss.php?typ=emsc");
        feed.setNumEntries(50);
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
                
               
       var title= div.appendChild(document.createTextNode(entry.title));
       var spazio= div.appendChild(document.createTextNode('      '));
       var link = div.appendChild(document.createTextNode(entry.link));
       
       
        container.appendChild(div);
              }
            }
          });
        
        }
        google.setOnLoadCallback(initialize);
        </script>

    fino a qui ok... nel mio div appare:


    _title + link


    ma ora arriva il bello:

    ammettiamo per assurdo che il mio codice sia questo:

    codice:
    <script type="text/javascript">
        google.load("feeds", "1");
        function initialize() {
          var feed = new google.feeds.Feed("http://www.emsc-csem.org/service/rss/rss.php?typ=emsc");
        feed.setNumEntries(50);
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
                
               
       var title= div.appendChild(document.createTextNode(entry.title));
       var spazio= div.appendChild(document.createTextNode('      '));
       var link = div.appendChild(document.createTextNode(entry.description));
       
       
        container.appendChild(div);
              }
            }
          });
        
        }
        google.setOnLoadCallback(initialize);
        </script>

    nel mio div ho questo risultato:


    title + undefined



    non cotinuo a capire il perché !


    il feed è strutturato in questo modo:



    codice:
    <item>
          <title>ML 3.0  OFFSHORE TARAPACA, CHILE</title>
          <link>http://www.emsc-csem.org/Earthquake/earthquake.php?id=370883</link>
       <geo:lat>-20.49</geo:lat>
       <geo:long>-70.87</geo:long>
       <emsc:depth>40  </emsc:depth>
       <emsc:magnitude>ML 3.0</emsc:magnitude>
       <emsc:time>2014-04-09 12:34:19 UTC</emsc:time>
       <pubDate>Wed, 09 Apr 2014 12:47:00 +0000</pubDate>
       <status>REVIEWED</status>
       <guid>http://www.emsc-csem.org/Earthquake/earthquake.php?id=370883</guid>
       <comments>2014-04-09 12:34:19 UTC</comments>
       <description>  <=!=[=C=D=A=T=A=[ tanto codice ]=]=> </description>
    </item>
    <item>
          <title>ML 3.0  OFFSHORE TARAPACA, CHILE</title>
          <link>http://www.emsc-csem.org/Earthquake/earthquake.php?id=370883</link>
       <geo:lat>-20.49</geo:lat>
       <geo:long>-70.87</geo:long>
       <emsc:depth>40  </emsc:depth>
       <emsc:magnitude>ML 3.0</emsc:magnitude>
       <emsc:time>2014-04-09 12:34:19 UTC</emsc:time>
       <pubDate>Wed, 09 Apr 2014 12:47:00 +0000</pubDate>
       <status>REVIEWED</status>
       <guid>http://www.emsc-csem.org/Earthquake/earthquake.php?id=370883</guid>
       <comments>2014-04-09 12:34:19 UTC</comments>
       <description> <=!=[=C=D=A=T=A=[ tanto codice ]=]=> </description>
    </item>


    mi sapete spiegare il perché ?????????????????????
    Ultima modifica di Rodrigoson6; 09-04-2014 a 17:31

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.