我有一个节点 js 服务器在我的本地机器上运行。如果你访问它,它只会返回一个 JSON 字符串。我有这个其他 html 文件
我想从节点 js 文件中获取字符串。如果我http://127.0.0.1:41302
在浏览器上访问,那么我可以看到该字符串,但在这里它一直进入错误函数。
这是它记录的内容
Request Failed: parsererror, SyntaxError: Invalid character
有谁知道出了什么问题?
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script type="text/javascript" src="jquery-2.1.0-beta1.js"></script>
<script>
$(function() {
var jqxhr = $.getJSON( "http://127.0.0.1:41302", function() {
alert( "success" );
})
.done(function() {
alert( "second success" );
})
.fail(function( jqxhr, textStatus, error ) {
var err = textStatus + ", " + error;
alert(err);
console.log( "Request Failed: " + err );
})
.always(function() {
alert( "finished" );
});
});
</script>
</head>
<body>
</body>
</html>
这是字符串(如果我访问该页面,我会从网络浏览器复制它)
'[{"created_at":"Fri Sep 20 22:52:25 +0000 2013","id":381189131721658368,"id_str":"381189131721658368","text":"OH: \\"Can I get the Pantene numbers on those colors?\\"","source":"web","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":12279882,"id_str":"12279882","name":"Timothy Yip","screen_name":"tyip","location":"San Francisco, CA, USA","description":"Legal Counsel at Twitter\\r\\nAspiring to be an expert in the law of the horse.","url":null,"entities":{"description":{"urls":[]}},"protected":false,"followers_count":7011,"friends_count":942,"listed_count":130,"created_at":"Tue Jan 15 16:05:58 +0000 2008","favourites_count":1206,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":5808,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"1A1B1F","profile_background_image_url":"http:\\/\\/abs.twimg.com\\/images\\/themes\\/theme9\\/bg.gif","profile_background_image_url_https":"https:\\/\\/abs.twimg.com\\/images\\/themes\\/theme9\\/bg.gif","profile_background_tile":false,"profile_image_url":"http:\\/\\/a0.twimg.com\\/profile_images\\/644038609\\/Picture_3_normal.jpg","profile_image_url_https":"https:\\/\\/si0.twimg.com\\/profile_images\\/644038609\\/Picture_3_normal.jpg","profile_banner_url":"https:\\/\\/pbs.twimg.com\\/profile_banners\\/12279882\\/1347983364","profile_link_color":"2FC2EF","profile_sidebar_border_color":"181A1E","profile_sidebar_fill_color":"252429","profile_text_color":"666666","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":false,"notifications":null},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweet_count":0,"favorite_count":3,"entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"},{"created_at":"Fri Sep 20 19:15:03 +0000 2013","id":381134427314987008,"id_str":"381134427314987008","text":"My buddies got an airbnb at a farm. Gonna go get drunk in a barn. This owns.","source":"\\u003ca href=\\"http:\\/\\/twitter.com\\/download\\/iphone\\" rel=\\"nofollow\\"\\u003eTwitter for iPhone\\u003c\\/a\\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":13462502,"id_str":"13462502","name":"truebe","screen_name":"TRUEBE","location":"San Francisco, CA","description":"Former historian, now doing Platform Operations for Twitter, Inc. Last of the mythical race of giants.","url":"http:\\/\\/t.co\\/4GRKsvrmrB","entities":{"url":{"urls":[{"url":"http:\\/\\/t.co\\/4GRKsvrmrB","expanded_url":"http:\\/\\/www.chillestmonkey.com","display_url":"chillestmonkey.com","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":6110,"friends_count":477,"listed_count":103,"created_at":"Thu Feb 14 06:38:16 +0000 2008","favourites_count":9699,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":29243,"lang":"en","contributors_enabled":false,"is_translator":false,"profile_background_color":"131516","profile_background_image_url":"http:\\/\\/a0.twimg.com\\/profile_background_images\\/555601201\\/believe.jpg","profile_background_image_url_https":"https:\\/\\/si0.twimg.com\\/profile_background_images\\/555601201\\/believe.jpg","profile_background_tile":false,"profile_image_url":"http:\\/\\/a0.twimg.com\\/profile_images\\/378800000120859344\\/8c2ec70e5d263ae1bb8fe7e7355d101c_normal.jpeg","profile_image_url_https":"https:\\/\\/si0.twimg.com\\/profile_images\\/378800000120859344\\/8c2ec70e5d263ae1bb8fe7e7355d101c_normal.jpeg","profile_banner_url":"https:\\/\\/pbs.twimg.com\\/profile_banners\\/13462502\\/1363035024","profile_link_color":"009999","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"EFEFEF","profile_text_color":"333333","profile_use_background_image":true,"default_profile":false,"default_profile_image":false,"following":null,"follow_request_sent":false,"notifications":null},"geo":{"type":"Point","coordinates":[43.20438122,-89.60351670]},"coordinates":{"type":"Point","coordinates":[-89.60351670,43.20438122]},"place":{"id":"5808604cfb35e14f","url":"https:\\/\\/api.twitter.com\\/1.1\\/geo\\/id\\/5808604cfb35e14f.json","place_type":"city","name":"Berry","full_name":"Berry, WI","country_code":"US","country":"United States","bounding_box":{"type":"Polygon","coordinates":[[[-89.719779,43.118389],[-89.600135,43.118389],[-89.600135,43.20644],[-89.719779,43.20644]]]},"attributes":{}},"contributors":null,"retweet_count":0,"favorite_count":5,"entities":{"hashtags":[],"symbols":[],"urls":[],"user_mentions":[]},"favorited":false,"retweeted":false,"lang":"en"}]'