Answer the question
In order to leave comments, you need to log in
How to pass PHP array to JS via CUtil::PHPToJSObject()?
Good afternoon.
I'm confused and don't understand. Please explain why:
In the file result_modifier.php at the end of the file, I write to a new array some data from $arResult (they are sorted out a little earlier and stored in $arElementsToJS)
?><script type="text/javascript">
var arElementsObj = new arElements(<?=CUtil::PHPToJSObject($arElementsToJS); // передаем массив в JS?>);
</script><?
arElements = function (arParams) {
if (typeof arParams === 'object')
{
this.arParams = arParams;
console.log(arParams);
}
};
var newvar = '';
arElements = function (arParams) {
if (typeof arParams === 'object')
{
newvar = arParams;
}
};
console.log(newvar);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question