0

I can not add JS code into PHP code

JavaScript File:

 $.each(data.data,function(i,modul){
 tb.append("<p><?php if (!is_dir($rootPath . '/Includes/'" + value.id+ "'")) { ?> <span>Test</span><?php } else { ?> <span>Test</span><?php } ?></p>"});

This line:

 ' + value.id+ ' = This is a JS code

Where do I make mistakes? Thanks

John
  • 1
  • 1
  • 3
    That's not how php/javascript work... – clearshot66 May 09 '17 at 18:38
  • 2
    A good IDE will point out that you have a huge syntax error with mismatched quotes. Also, PHP runs before the page is sent to the browser, javascript after. You can't manipulate PHP variables in javascript. – aynber May 09 '17 at 18:38
  • I use PHPstorm but syntax is normal @aynber – John May 09 '17 at 18:50

0 Answers0