0

jQuery:

$(document).ready(function(){

var url='http://query.yahooapis.com/v1/public/yql?q=select * from html where url=\'http://stackoverflow.com/\' and xpath=\'//div[@id="question-mini-list"]//h3//a                       \'&format=json&callback=?';

    $.getJSON( url, function(data){
        $.each(data.query.results.a, function(){       
            $('#stack').append('<div><a href="http://stackoverflow.com'+this.href +'">'+this.content+'</a></div>')          
        })
    })
});

HTML

<section id="stack">

</section>

The jQuery code is borrowed from an earlier post (Thanks!), but my question is: Shouldn't the jQuery code run when the page loads, the way it's displayed here? Im using coda 2. The jQuery is saved as .js-file, and the html is saved as .html. Both files are located in the same directory.

Thanks for any and all help!

6
  • 1
    Works fine for me... jsfiddle.net/G4jDz Commented Jun 16, 2013 at 20:26
  • 2
    Let's see your script references. Commented Jun 16, 2013 at 20:31
  • @Zenith I know. But it didn't work in coda 2. Commented Jun 16, 2013 at 20:48
  • @Nilzone The problem was to do with your script placement (which you should have shown instead of making people guess) not coda 2 Commented Jun 16, 2013 at 20:49
  • @Zenith You're right. I should have added the all my HTML-instead of parts. Commented Jun 16, 2013 at 21:24

1 Answer 1

1

Make sure you define a link to your javascript file in the <head> of your index.html page.

<script rel="javascript" type="text/javascript" src="path/to/javascript.js"></script>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.