Get checkbox value in jQuery

To get the value of the Value attribute you can do something like this: Or if you have set a class or id for it, you can: However this will return the same value whether it is checked or not, this can be confusing as it is different to the submitted form behaviour. To check … Read more

What’s the point of the X-Requested-With header?

A good reason is for security – this can prevent CSRF attacks because this header cannot be added to the AJAX request cross domain without the consent of the server via CORS. Only the following headers are allowed across origins: Accept Accept-Language Content-Language Last-Event-ID Content-Type any others cause a “pre-flight” request to be issued in CORS supported browsers. … Read more

Obtain form input fields using jQuery?

Thanks to the tip from Simon_Weaver, here is another way you could do it, using serializeArray: Note that this snippet will fail on <select multiple> elements. It appears that the new HTML 5 form inputs don’t work with serializeArray in jQuery version 1.3. This works in version 1.4+