I'm struggling to work out how to test my code.
I have a script in PHP which takes values from a string and puts them together into a message to be mailed.
The form is submitted using AJAX as follows:
$.ajax({
type: "POST",
url: "actions/sendForm.php",
data: dataString,
success: console.log('Success!')
});
The data is supposed to be passed to the PHP script. The var dataString
looks like this:
var dataString = 'name='+name+'&company='+company+'&email='+email+'&phone='+phone+'&message='+message+'&signup='+signUp;
I am then trying to access these vars as such:
parse_str($dataString);
echo $name;
echo $company;
echo $email;
echo $phone;
echo $message;
echo $signUp;
My issue is that something is not happening, and I cannot test my PHP script any more because I am submitting via AJAX, so I never actually hit the script with the correct data.
How can I test a script working/echo variables etc when the form is submitted via AJAX?