Suppose i have a textarea in a form named urlslist
where the user will input a list of urls , one on each line.I handle the submit via ajax with query as follows.
$(function () {
$("#urlslist").submit(function(e) {
//prevent Default functionality
e.preventDefault();
//get the action-url of the form
var actionurl = e.currentTarget.action;
//do your own request an handle the results
$.ajax({
url: actionurl,
type: 'post',
dataType: 'json',
data: $("#urlslist").serialize(),
success: function(data) {
//put the result in another textarea here
}
});
});
});
Then i display the result of my processing (i.e another url for each input) in another textarea. It works well but i want to improve it so that old urls don't get submitted to the server via ajax while not clearing either of the textareas.
Edit 1
I think i need to demonstrate this with an example.
Suppose that the urlslist
textarea contain one url.I click on submit and i get a result.Now i add another url in the urlslist
and click on submit again.Now there will be 2 urls in the post request.How can i make sure that only new urls are sent.