SyntaxError:期望表达式,得到'<'使用jsonp

时间:2015-09-09 04:16:03

标签: javascript angularjs api http-headers syntax-error

所以我在向服务器返回api的请求时遇到了麻烦。然后我选择使用Jsonp返回数据。我在响应中获取数据,但我的javascript控制台说有一个

syntaxError: expecting expression, got '<'.

有人知道这是否是来自服务器的某种安全响应,因为我正在对此api进行跨域请求?

这是我的角度控制器

app.controller('bibleController', function ($scope, $http, bibleService) {

    //Get A chapter from the bible
    $scope.search = function() {
        return $http.jsonp("http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=" + $scope.bo + $scope.chap, {
        }).success(function (data, status, headers, config) {
            $scope.output = "help"; //this is what you're after.
        }).error(function (data, status, headers, config) {
            $scope.Message = "Oops... something went wrong";

        });

    }

});

我真的很想知道是怎么回事。我想返回JSON for angular,但是这个服务器只返回xml或html。我正在回复HTML。这是回复。

<div class="esv"><h2>James 2 <object type="application/x-shockwave-flash"  data="http://www.esvapi.org/assets/play.swf?myUrl=hw%2F59002001-59002026" width="40" height="12" class="audio"><param name="movie" value="http://www.esvapi.org/assets/play.swf?myUrl=hw%2F59002001-59002026" /><param name="wmode" value="transparent" /></object></h2>
<div class="esv-text"><h3 id="p59002001.01-1">The Sin of Partiality</h3>
<p id="p59002001.05-1"><span class="chapter-num" id="v59002001-1">2:1&nbsp;</span>My brothers,<span class="footnote">&nbsp;<a href="#f1" id="b1" title="Or 'brothers and sisters'; also verses 5, 14">[1]</a></span> show no partiality as you hold the faith in our Lord Jesus Christ, the Lord of glory. <span class="verse-num" id="v59002002-1">2&nbsp;</span>For if a man wearing a gold ring and fine clothing comes into your assembly, and a poor man in shabby clothing also comes in, <span class="verse-num" id="v59002003-1">3&nbsp;</span>and if you pay attention to the one who wears the fine clothing and say, &#8220;You sit here in a good place,&#8221; while you say to the poor man, &#8220;You stand over there,&#8221; or, &#8220;Sit down at my feet,&#8221; <span class="verse-num" id="v59002004-1">4&nbsp;</span>have you not then made distinctions among yourselves and become judges with evil thoughts? <span class="verse-num" id="v59002005-1">5&nbsp;</span>Listen, my beloved brothers, has not God chosen those who are poor in the world to be rich in faith and heirs of the kingdom, which he has promised to those who love him? <span class="verse-num" id="v59002006-1">6&nbsp;</span>But you have dishonored the poor man. Are not the rich the ones who oppress you, and the ones who drag you into court? <span class="verse-num" id="v59002007-1">7&nbsp;</span>Are they not the ones who blaspheme the honorable name by which you were called?</p>
 <p id="p59002008.01-1"><span class="verse-num" id="v59002008-1">8&nbsp;</span>If you really fulfill the royal law according to the Scripture, &#8220;You shall love your neighbor as yourself,&#8221; you are doing well. <span class="verse-num" id="v59002009-1">9&nbsp;</span>But if you show partiality, you are committing sin and are convicted by the law as transgressors. <span class="verse-num" id="v59002010-1">10&nbsp;</span>For whoever keeps the whole law but fails in one point has become accountable for all of it. <span class="verse-num" id="v59002011-1">11&nbsp;</span>For he who said, &#8220;Do not commit adultery,&#8221; also said, &#8220;Do not murder.&#8221; If you do not commit adultery but do murder, you have become a transgressor of the law. <span class="verse-num" id="v59002012-1">12&nbsp;</span>So speak and so act as those who are to be judged under the law of liberty. <span class="verse-num" id="v59002013-1">13&nbsp;</span>For judgment is without mercy to one who has shown no mercy. Mercy triumphs over judgment.</p>
 <h3 id="p59002014.01-1">Faith Without Works Is Dead</h3>
<p id="p59002014.06-1"><span class="verse-num" id="v59002014-1">14&nbsp;</span>What good is it, my brothers, if someone says he has faith but does not have works? Can that faith save him? <span class="verse-num" id="v59002015-1">15&nbsp;</span>If a brother or sister is poorly clothed and lacking in daily food, <span class="verse-num" id="v59002016-1">16&nbsp;</span>and one of you says to them, &#8220;Go in peace, be warmed and filled,&#8221; without giving them the things needed for the body, what good<span class="footnote">&nbsp;<a href="#f2" id="b2" title="Or 'benefit'">[2]</a></span> is that? <span class="verse-num" id="v59002017-1">17&nbsp;</span>So also faith by itself, if it does not have works, is dead.</p>
 <p id="p59002018.01-1"><span class="verse-num" id="v59002018-1">18&nbsp;</span>But someone will say, &#8220;You have faith and I have works.&#8221; Show me your faith apart from your works, and I will show you my faith by my works. <span class="verse-num" id="v59002019-1">19&nbsp;</span>You believe that God is one; you do well. Even the demons believe&#8212;and shudder! <span class="verse-num" id="v59002020-1">20&nbsp;</span>Do you want to be shown, you foolish person, that faith apart from works is useless? <span class="verse-num" id="v59002021-1">21&nbsp;</span>Was not Abraham our father justified by works when he offered up his son Isaac on the altar? <span class="verse-num" id="v59002022-1">22&nbsp;</span>You see that faith was active along with his works, and faith was completed by his works; <span class="verse-num" id="v59002023-1">23&nbsp;</span>and the Scripture was fulfilled that says, &#8220;Abraham believed God, and it was counted to him as righteousness&#8221;&#8212;and he was called a friend of God. <span class="verse-num" id="v59002024-1">24&nbsp;</span>You see that a person is justified by works and not by faith alone. <span class="verse-num" id="v59002025-1">25&nbsp;</span>And in the same way was not also Rahab the prostitute justified by works when she received the messengers and sent them out by another way? <span class="verse-num" id="v59002026-1">26&nbsp;</span>For as the body apart from the spirit is dead, so also faith apart from works is dead.  (<a href="http://www.esv.org" class="copyright">ESV</a>)</p>
</div>
<div class="footnotes">
<h3>Footnotes</h3>
<p><span class="footnote"><a href="#b1" id="f1">[1]</a></span> <span class="footnote-ref">2:1</span> Or <em>brothers and sisters</em>; also verses 5, 14
<br />
<span class="footnote"><a href="#b2" id="f2">[2]</a></span> <span class="footnote-ref">2:16</span> Or <em>benefit</em>
</p>
</div>
</div>

常规和响应标题

Remote Address:75.101.167.237:80
Request URL:http://www.esvapi.org/v2/rest/passageQuery?key=IP&passage=james2
Request Method:GET
Status Code:200 OK (from cache)
Response Headers
Content-Length:5583
Content-Location:passageQuery.php
Content-Type:text/html
Date:Tue, 08 Sep 2015 18:19:13 GMT
Expires:Wed, 09 Sep 2015 18:19:13 +0000
Server:nginx/0.7.62
TCN:choice
Vary:negotiate
X-Powered-By:PHP/5.2.10-2ubuntu6.4

查询字符串和请求标题

Provisional headers are shown
Accept:*/*
Referer:http://localhost:59324/
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36
Query String Parameters
view source
view URL encoded
key:IP
passage:james2

我真的很想让这个api工作!

0 个答案:

没有答案