2013-03-27 61 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