can’t find an answer to this one…
I have a form that detects changed fields via jquery and adds edited if it’s edited and adds editable if it’s not edited.
On a button click I want it to find all the fields with class ‘edited’ and store them to be sent via ajax to a php file to update the database. I built the PHP file and can pass ALL the form fields, but I only want to pass the changed ones. This specific instance is being used for a “My Account” page which will update their email, info, password, etc.
Here’s the loop to find them all:
if ($(".edited").length > 0) {
$(".edited").each(function() {
$(this).WhatToDoNow();
});
What’s the way to do this with jQuery.ajax? I need each to be identifiable by the PHP file. Also, is it bad not to md5 the old password before sending it over to the PHP file?
Does it matter if we’re using json or not? What’s best practice?
Thanks guys for all your help!!! This community rocks.
- Brenden
So long as you’re actually submitting the form (not just reading the individual values and sending them to the server), you can just set the inputs that aren’t edited to have the “disabled” attribute true. Disabled form elements aren’t submitted to the server.
Honestly, though, I think it’s better to just send the entire form to the server and process the changed//not changed logic there. What happens if the user opens a second form and submits that one, and then goes back to the first? Or if javascript is disabled?