Begginer's question.
Can I use PHP in javascript?
For example in jquery,
...
...
triggers.eq(1).post('<?php admin/categories/delete/'. $list['id']; ?>);
Begginer's question.
Can I use PHP in javascript?
For example in jquery,
...
...
triggers.eq(1).post('<?php admin/categories/delete/'. $list['id']; ?>);
What you want to do is possible, if the javascript is in an PHP file,
triggers.eq(1).post('admin/categories/delete/<?= $list['id'] ?>');
The PHP doenst run in the javascript, but the variable is replaced when the page is sent to the client.
No, you cannot use PHP within JavaScript. Think about it this way: you need a PHP interpreter/runtime to execute the PHP, and browsers do not contain this. Based on your code snippet above, you could instead send an ajax call to a PHP script on the server.
I suppose you could pass PHP code to a server-side script and interpret/execute it, but you'd still need ajax or a full GET/POST request, and it would never be a good thing to do because of how easy it would be for malicious code injection.