0

私はjsFiddleで例として試しました

$.get('/user/login/', function(content){  /* (jsFiddle.net/user/login is in the same domain) */
    alert($('*',content).html()); 
});

しかし、それは戻ります

<a href="/">JSFiddle</a> 

私は何を間違っていますか?たとえば、HTML のタイトルを取得したいのですが、$('title',content) が機能しません

4

3 に答える 3

1

Ajaxなしでこれを行うことができます。

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Load remote content into object element</title>
  </head>
  <body>
    <div id="siteloader"></div>​
    <script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script>
      $("#siteloader").html('<object data="http://tired.com/">');
    </script>
  </body>
</html>

ページを取得したら、解析を試みます。

于 2013-08-30T12:56:02.163 に答える
1

jsfiddles ログイン ページをチェックします。何かのようなもの

http://jsfiddle.net/user/login/

/echo/json/URLとして次のようなものを使用できます:

<div class='wrapper'>
<p>JSON will be received in 3 seconds</p>
<ul id='post'></ul>
</div>

new Request.JSON({
    url: '/echo/json/',
    data: {
        json: JSON.encode({
            text: 'some text',
            array: [1, 2, 'three'],
            object: {
                par1: 'another text',
                par2: [3, 2, 'one'],
                par3: {}
            }
        }),
        delay: 3
    },
    onSuccess: function(response) {
        show_response(response, $('post'));
    }
}).send();

show_response = function(obj, result) {
    $H(obj).each(function(v, k) {
        new Element('li', {
            text: k + ': ' + v
        }).inject(result);
    });
    result.highlight();
};

jsfiddle デモ: http://jsfiddle.net/zalun/QsHw4/#

于 2013-08-30T13:06:22.967 に答える
1

私の知る限り、JSFiddle は AJAX 呼び出しを許可しません。

編集:しかし、私はそれを使用していませんが、彼らはある種のシミュレーションを提供していますhttp://doc.jsfiddle.net/use/echo.html

于 2013-08-30T12:54:17.000 に答える