Answer the question
In order to leave comments, you need to log in
How to pass (export/import) a variable from javascript to php?
There is a variable in js file:
const orderMessage = `шаблонная строка в виде сообщения на почту`;
$body = ' значение импортированной переменной (то есть та самая шаблонная строка) ';
Answer the question
In order to leave comments, you need to log in
If there is an AJAX submit in the code, then the best solution would be to add this secret string to the form.
Just add an input with the hidden parameter, and when processing the form submission, you set the value of this input in the form to the desired string.
Use AJAX (needs to be improved)
$(document).ready(function(){
$.ajax({ type: 'POST', url: 'LINK_TO_YOUR_SENDMAIL.PHP', success: function(response){
// SOME_ACTION
}
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question