I have a phone number field on admin page that i have created using settings API. I have specified a sanitization function that removes everthing from the input except for numbers. Now if i submit the data by clicking the submit button data is sanitized properly but if a try to do this using ajax post request it does not sanitize the data but saves the unsanitized data in the

jQuery( '#theme_phone_save' ).click( function( e ) {

var formData = jQuery( "#theme_form_phone" ).serializeArray();

jQuery.post('options.php', formData, function(data, textStatus, xhr) {
    console.log( data );
} ); 

How do i sanitize the form data submitted using ajax?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.