English 中文(简体)
YQL JSON 说稿没有返回?
原标题:YQL JSON script not returning?

我在此有一段文字,在。 为什么没有列入以下的法典?

ajax.html:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">

<html dir="ltr" lang="en-US">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Cross-Domain Ajax Demo</title>
    </head>
    <body>
        <div id="container">
            <form>
                <p><label>Type a URL:</label><input type="text" name="sitename" id="sitename"/></p>
                <p><input type="submit" name="submit" id="submit" value="Make Cross Domain Ajax request"</p>
            </form>
        </div>

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" charset="utf-8"></script>
        <script type="text/javascript" src="cross-domain-requests.js"></script>

        <script type="text/javascript">
            $( form ).submit(function() {
                var path = "www.google.com";
                requestCrossDomain(path, function(results) {
                    $( #container ).html(results);
                });
                return false;
            });
        </script>
    </body>
</html>

www.un.org/Depts/DGACM/index_french.htm

// Accepts a URL and a callback function to run.
function requestCrossDomain( site, callback ) {

    // If no URL was passed, exit.
    if ( !site ) {
        alert( No site was passed. );
        return false;
    }

    // Take the provided URL, and add it to a YQL query. Make sure you encode it!
    var yql =  http://query.yahooapis.com/v1/public/yql?q=  + encodeURIComponent( select * from html where url="  + site +  " ) +  &format=xml&callback=cbFunc ;

    // Request that YSQL string, and run a callback function.
    // Pass a defined function to prevent cache-busting.
    $.getJSON( yql, cbFunc );

    function cbFunc(data) {
    // If we have something to work with...
    if ( data.results[0] ) {
        // Strip out all script tags, for security reasons.
        // BE VERY CAREFUL. This helps, but we should do more.
        data = data.results[0].replace(/<script[^>]*>[sS]*?</script>/gi,   );

        // If the user passed a callback, and it
        // is a function, call it, and send through the data var.
        if ( typeof callback ===  function ) {
            callback(data);
        }
    }
    // Else, maybe we requested a site that doesn t exist, and nothing returned.
    else throw new Error( Nothing returned from getJSON. );
    }
}

(描述和Ajax相对较新,因此,如果我做任何事情,我会预先道歉。)

最佳回答

• 改变瓦尔和克勒的警示,以追捕? 以及从xml类中选取的表述:

var yql =  http://query.yahooapis.com/v1/public/yql?q=  + encodeURIComponent( select * from xml where url="  + site +  " ) +  &format=xml&callback=? ;
问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签