0

我正在使用 instagram ruby​​ gem。如果我在下面做超过 2 个请求,我得到的错误是什么。

现在,对于前两个请求,它显示了这个

Processing by HomesController#index as JS
Processing by HomesController#index as */*

因此,当第三个请求现在发生时,它会误入(如上所述)这个

    Completed 500 Internal Server Error in 4525ms

JSON::ParserError (757: unexpected token at '<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" class="hl-en not-logged-in ">
<head>
    <meta charset="UTF-8" />
    <title>Page Not Found &bull; Instagram</title>

    <meta name="robots" content="noimageindex" />

    <link rel="Shortcut Icon" type="image/x-icon" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/images/ico/favicon.ico" />

    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black" />

    <link rel="apple-touch-icon-precomposed" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/images/ico/apple-touch-icon-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/images/ico/apple-touch-icon-72x72-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="114x114" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/images/ico/apple-touch-icon-114x114-precomposed.png" />
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/images/ico/apple-touch-icon-144x144-precomposed.png" />


    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />



        <script type="text/javascript" src="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/scripts/jquery.js"></script>
        <script type="text/javascript" src="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/scripts/bluebar.js"></script>

        <script type="text/javascript" src="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/cache/strings/strings_en.js"></script>
        <script>
window._csrf_token = 'NOTPROVIDED';
window._jscalls = [


];
</script>


<script type="text/javascript" src="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/cache/polyfills/polyfill_old.js"></script>
<script data-main="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/cache/modules/main.js" src="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/scripts/require.js"></script>





        <link rel="stylesheet" type="text/css" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/cache/bluebar/bluebar_new.css" />



    <link rel="stylesheet" type="text/css" href="//d36xtkk24g8jdx.cloudfront.net/bluebar/f4f8a28/cache/distillery/dialog-main.css"/>


</head>
<body class=" p-error dialog-404">

<div class="root">


    <div class="page">


                <header class="top-bar top-bar-new">
    <div class="top-bar-wrapper">
        <h1 class="logo"><a href="/">Instagram</a></h1>

        <div class="top-bar-left">
            <ul class="top-bar-actions">
                <li>
                    <a class="top-bar-home" href="/" label=Home><i></i></a>
                </li>
            </ul>
            <div class="top-bar-search" id="top-bar-search">
                &nbsp;
            </div>
        </div>

        <div class="top-bar-right account-state" id="top_bar_right">
            <ul class="top-bar-actions">


                <li id="link_profile" class="link-signin">
                    <a href="javascript:;" class="loginLink">
                        <i></i>
                        <strong>Log in</strong>
                    </a>
                </li>

            </ul>


          </div>
    </div>
</header> <!-- .top-bar -->




        <div class="main">

    <div class="error-container">


    <h2>Page Not Found</h2>

    <p>This page could not be found.<br />You might have followed an incorrect link.</p>


    </div>

        </div> <!-- .main -->


    </div> <!-- .page -->


    <footer class="page-footer" role="contentinfo">
        <div class="wrapper">
            <nav>
                <ul>
                    <li><a href="/about/us/">About us</a></li>
                    <li><a href="http://help.instagram.com/">Support</a></li>
                    <li><a href="http://blog.instagram.com/">Blog</a></li>
                    <li><a href="/developer/">API</a></li>
                    <li><a href="/about/jobs/">Jobs</a></li>
                    <li><a href="/about/legal/privacy/">Privacy</a></li>
                    <li><a href="/about/legal/terms/">Terms</a></li>
                </ul>
            </nav>

            <p class="copyright">&copy; 2013 Instagram</p>
        </div>
    </footer>



<div id="reactModalMountPoint"></div>
</div> <!-- .root -->







<script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-18105282-1']);
    _gaq.push(['_setDomainName', 'none']);
    _gaq.push(['_setAllowLinker', true]);

    _gaq.push(['_trackPageview']);
    (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
</script>

</body>
</html>'

我认为标题有问题?既然我是通过ajax来做这个过程的,我怎么能强制它通过JS来处理呢?因为这似乎在这里工作我相信。

这是我的ajax代码

{
            $.ajax({
            url: /home,
            method: "post",
            data: {
                // data goes here
            },
            success: function(html)
            {
                if(html)
                {       

                            // html goes here
                }else
                {
                   // html goes here</center>');
                }
            }
4

3 回答 3

0

我认为如果您在特定时间执行多个请求,instagram 会阻止您的请求

于 2013-04-02T20:36:03.293 回答
0

Instagram is serving up an error page instead of the JSON you expect. You need to check the response's status code (in this case it would be 404 instead of 200) to find out if the payload is JSON or HTML in the case of the error page.

于 2013-04-02T20:37:23.383 回答
0

经过这么多的工作,我发现我的案例是因为 JSON 数据内容中的某些东西正在搞砸事情。那是我的情况(我也讨厌 500 状态对错误如此含糊)

于 2014-02-27T07:09:48.500 回答