There is a page.
It displays information echo "$catalogVars['goodsDesc']";
You need to send this variable to some script script.php
The following javascript was written.

 function set_description() { var text_prdct = "<?=$catalogVars['goodsDesc']?>"; jQuery.ajax({ url:'/forma/desc_prdct.php' , type:'POST' , data:{name: "<?=$catalogVars['goodsDesc']?>" } , success: function(response) { document.write(response); } }); } 

Normal lines it sends.
However, the following problem occurred. Variable content

 <div style="text-align: center;"> <img alt="Стенд и картинки для уголка безопасности" border="0" src="/images/goods/umey_deystvovat.jpg" title="Стенд и картинки для уголка безопасности" /></div><div style="text-align: center;"><div style="text-align: center;"> <img alt="Пожарная безопасность в школе" border="0" src="/images/goods/pb_foto_2.jpg" title="Пожарная безопасность в школе" /></div> <div style="text-align: center;"> <br /> Пожарная безопасность в школе<br /> &nbsp;</div> <p style="text-align: justify"> Пожар всегда был и остается большой опасностью. А дети в несколько раз чаще взрослых становятся жертвами огня. Каждому ребенку необходимо знать, что делать в случае возгорания, поэтому в школе необходим уголок, посвященный действиям при пожаре, должны проводиться специальные занятия. Информационный школьный стенд с картинками &laquo;Умей действовать при пожаре&raquo; прекрасно подойдет для оформления уголка пожарной безопасности, кабинета ОБЖ в школе, а также на роль инструмента для обучающих игр на тему пожарной безопасности. Форма и яркие цвета стенда будут привлекать внимание детей к информации, способствовать ее запоминанию. <br /> <br /> В цену стенда входит комплект ламинированных картинок по безопасности <a href="/posters/pojar.html">Умей действовать при пожаре</a> 10пл.</p> 

The content of a variable is always different. If you do not screen quotes, the function is undefined; in the presence of carbon brackets, var_dump shows an empty string.

  • As an option, you can save the variable in the session - votanko
  • one
    Maybe it will be easier to send the ID of this directory or what is your description attached to, and in script.php you can get this description? - EatMyDust
  • this is the problem with ids. - votanko
  • one
    encode the line in base64 and decode it in script.php) - EatMyDust
  • I can not give the variable javascript to the value of the variable php. tried to shield - does not help. - votanko

1 answer 1

And if you try

 var text_prdct = '<?php echo strtr(addslashes($catalogVars['goodsDesc']),"\n",null);?>'; 

Here you need to use single quotes, pre-filming them in the data, as well as, at least, remove line breaks from the data.