Pregunta

I know how to use ajax for submitting a form and all. What I am concerned about is, what is actually happening in the background when a form is submitted via ajax.

How are the values transferred? Encrypted or not? And what is the need of specifying submission type, I mean get or post, if the URL is not showing the form fields?

Edit: Found this on w3schools:

  • GET requests can be cached

  • GET requests remain in the browser history

  • GET requests can be bookmarked

  • GET requests should never be used when dealing with sensitive data

  • GET requests have length restrictions

  • GET requests should be used only to retrieve data

  • POST requests are never cached

  • POST requests do not remain in the browser history
  • POST requests cannot be bookmarked
  • POST requests have no restrictions on data length

How do these apply to ajax form submission?

¿Fue útil?

Solución

Basically, when you Ajax-submit a form, it is doing exact same thing as what would happen when you as a user GET or POST submit a form - except that it is done in an asynchronous thread by the browser - i.e. called XMLHttpRequest.

If you submit form as a GET request, all of the form values are stitched together as parameter strings and appended to the URL (form's ACTION URL) - prefixed by a ?. This means anyone who can intercept that communication can read the submitted form data even if request is sent to a HTTPS URL. The POST method sends form data as a separate block (from the URL) and if URL is HTTPS then form data gets encrypted.

It looks like you are just starting out in the world of web development - welcome to the world of programming. I would recommend reading up on some good web development/programming books (I don't want to promote any particular book here). Amazon may help suggest few good ones under "Web Development" kind of search terms.

Also, I suggest that you read up a little on GET vs. POST by googling for it (I can only include one or two links - google will show you hundreds).

Otros consejos

For the clear understanding & behind the scene things please refer the links given below.

http://www.jabet.com/

How does AJAX work?

Actually ajax request is same as the normal requests at the server end.

  1. GET or POST has their own use cases. for example: GET has a limit of data transfer depending on the browsers from 1KB to 10 KB. where POST has no such limits.

  2. For a server both AJAX & normal request both are same. so it depends on server code which method you wish to support.

  3. ajax requests are NOT encrypted.

http://www.w3schools.com/tags/ref_httpmethods.asp

It looks like you want a very detailed answer so you can find it yourself:

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top