user1050619
user1050619

Reputation: 20906

Do I need a form to POST data?

T'm planning to a Ajax calls to post some data. The data Im going to post is a simple string containing a IP that will be validated against regular expression.

I can do in Javascript but the Python socket module does it very simple..

Question:

  1. Do i always need a form to POST a request? I just need to pass a string?

Upvotes: 0

Views: 55

Answers (1)

Ciro Costa
Ciro Costa

Reputation: 2585

You might just perform a normal asynchronous post as you'd do with Javascript or jQuery for a certain URL with your data.

For doing so with javascript, just create a XMLHttpRequest with whatever you have and send it. With jQuery is even simpler.

jQuery:

$.post('/your_url' {
    your_item: value
    other_item: value2,

},
success: function(data) {
    alert(data);
});

edit: The answer is no. Just handle the result in a view anyway.

Upvotes: 1

Related Questions