Sunday 15 July 2012

php - Wordpress bloginfo('template_directory') not working in jquery -


I have a custom jquery file in the WordPress site and I'm trying to use bloginfo ('template_directory') Instead of typing the entire URL in the AJAX URL path, they are required to make variables specifically (especially at this time on a test site, so it is necessary to ensure everything goes on the actual domain when they go to a live site. ) However, whatever happens is That PHP is added to the URL, not the directory path.

What do I have at the moment:

  $ (document) .ready (Function () {var templateDir = "& lt ;? php bloginfo ('template_directory') ? & Gt; "// Login $ ('login-form'). ('Submit', function (e) {e. PreventDefault (); data string = $ (this). Serialize () + '& amp; AJAX = 1 '; $ .ajax ({type: "post", url: template dior + "/ inc /do-login.php", data: data string, cache: wrong, success: function (data) {.}}} }}};   

and what I get in the console error ..):

  Post http: //www./ .. ... /% 3C? Php% 20get_bloginfo ('template_directory')% 20?% 3E / inc / do-login.php 404 (none)   

Can someone shed some light on this?

< P> You need to create a Javascript snippet that saves the template dior in a variable, and you can use that variable later