I was heading down the rout of putting a button (.email_validate) on the survey to "validate the email". Respondent will push the button, call a .php script that makes the database check, and return a value of 1 or 0 depending on whether the "bad email" is present. I will update a hidden text question with the value and will only allow the survey to submit if the value is 1.
Everything works, except I'm having trouble returning the value to javascript via php. I have this in my temple.js.
$('.email_validate').click(function(){
//var email = document.getElementById('answer891188X349X2862SQ3').value;
var clickBtnValue = $(this).val();
var ajaxurl = '
www.domainname.com/surveyassets/email_op...=example@example.com
',
data = {'action': clickBtnValue};
$.post(ajaxurl, data, function (response) {
// Response div goes here.
var result = $.parseJSON(output);
alert(result + "<br>" + ajaxurl + "action performed successfully");
});
});
I'm getting an error in the console on the $.parseJSON line: Output is undefined. Any thoughts?