2013-03-27 53 views
0

我试图使用剪辑API(http://www.clipped.me/api.html)在用户提交文章网址时返回文章摘要。当用户提交一个合适的URL时,他们被重定向到一个带有JSON结果的新页面。我想保持用户在页面上,并在JavaScript中解析JSON字符串。我假设重定向与表单操作是脚本本身的链接有关,但我不确定这里要做什么。以下是代码。如何在提交表单后停止重定向到API调用结果?

<!DOCTYPE html> 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 

<head> 
<title>Summarize you will!</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> 
</head> 

<body> 

    <form action="http://clipped.me/algorithm/clippedapi.php?url=[URL]" method="get"> 
     <input type="text" name="url"/> 
     <input type="submit" value="Submit"/> 
    </form> 

</body> 

<script type="text/javascript"> 

</script> 


</html> 

回答

0

不要使用表单提交来调用API。改用AJAX调用。

+0

我会研究它。谢谢! – 2013-03-27 06:18:41