Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
50
rated 0 times [  56] [ 6]  / answers: 1 / hits: 33358  / 14 Years ago, tue, may 18, 2010, 12:00:00

My header is calling a javascript file which sends out an email:



<script type=text/javascript src=<?php bloginfo('template_directory') ?>/css/effects.js></script>


But inside this file, I have a jQuery code that calls a .php file that does the actual sending of the email:



$.ajax({
type: POST,
url: css/sendmail.php,
data: dataString`


But the script doesn't work, unless the url is:



<?php bloginfo('template_directory') ?>/css/sendmail.php


and not just:



css/sendmail.php


Is there any way to include a path to the wordpress template directory inside js?


More From » jquery

 Answers
10

You could create a Javascript snippet that saves the template dir in a variable, and use this later:



<script>
var templateDir = <?php bloginfo('template_directory') ?>;
</script>

[#96752] Saturday, May 15, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kalistaz

Total Points: 0
Total Questions: 100
Total Answers: 106

Location: Bermuda
Member since Thu, Apr 20, 2023
1 Year ago
;