-
-
Save Aleksandar-Mitic/8fb094af770496f926e988ea3dd648d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( document).ready( function() { | |
var userSubmitButton = document.getElementById( 'user-submit-button' ); | |
var adminAjaxRequest = function( formData, action ) { | |
$.ajax({ | |
type: 'POST', | |
dataType: 'json', | |
url: screenReaderText.adminAjax, | |
data: { | |
action: action, | |
data: formData, | |
submission: document.getElementById( 'xyq').value, | |
security: screenReaderText.security | |
}, | |
success: function(response) { | |
if ( true === response.success ) { | |
alert( 'this was a success' ); | |
} else { | |
alert( 'You Suck' ); | |
} | |
} | |
}); | |
}; | |
userSubmitButton.addEventListener( 'click', function(event) { | |
event.preventDefault(); | |
var formData = { | |
'name' : document.getElementById( 'user-name').value, | |
'email' : document.getElementById( 'user-email').value, | |
'question' : document.getElementById( 'user-entry-content').value, | |
'product' : document.getElementById( 'product').value | |
}; | |
adminAjaxRequest( formData, 'process_user_generated_post' ); | |
} ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment