Thursday, 15 April 2010

javascript - How to stop redirect to API call result after form submission? -


When a user submits an article url, then I use the Clamp API () to return text summary I am trying. When the user submits a suitable URL, they are redirected to a new page with the JSON result. I want to keep the user on the page and parse the JSON string in Javascript. I'm assuming that this redirect has to do with the fact that the form is a link to the verb script, but I'm not sure what to do here. Below is the code

   & Lt; Script src = "http://code.jquery.com/jquery-1.8.2.min.js" & gt; & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form action = "http://clipped.me/algorithm/clippedapi.php?url=[URL]" method = "find" & gt; & Lt; Input type = "text" name = "url" /> & Lt; Input type = "submit" value = "submit" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; Script type = "text / javascript" & gt; & Lt; / Script & gt; & Lt; / Html & gt;    

Do not use form submissions to make API calls. Instead use AJAX calls.

No comments:

Post a Comment