我很新的JavaScript和AJAX的。一位朋友已经开始帮我将发布状态更新App.net一种形式,但我不能得到它的工作。我敢肯定有很多错误的代码,但在此先感谢您的帮助。
<html>
<head>
<title>Post to App.net</title>
<link rel="stylesheet" type="text/css" href="style_post.css">
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<script>
function post()
</script>
<script type="text/javascript" language="javascript" src="count.js"></script>
<form id="post" method="post">
<textarea name="fixlength" value="What's on your mind?" id="posttext" maxlength="256" lengthcut="true"></textarea><br>
<input type="submit" value="Post" id="submit">
</form>
<label id="limitlbl_0" ><script> parseCharCounts(); </script></label>
<script type="text/javascript">
var frm = $('#post');
var token = window.location.href.substring(45,143),
var text = $('input[type="text"]').val()
frm.submit(function () {
$.ajax({
type: 'POST',
url: 'https://alpha-api.app.net/stream/0/posts',
data: {
text: 'test'
token: + token +'
},
success:
});
return false;
});
</script>
</body>
</html>
如果你是一个更大的应用程序,那么你肯定会需要得到Ajax调用工作(你可以做跨域的职位,以及被使用CORS)。然而,对于这种特殊的情况下,有一个简单的解决方案:
http://developers.app.net/docs/other/web-intents/
使用Web意图,你可以使用iframe或很容易将用户重定向到一个帖子的形式。只要使用正确的URL和你做。没有JS需要在所有。
下面是上面的例子:
https://alpha.app.net/intent/post/?text=%40adn%20When%20is%20the%20next%20meetup%3F