Wordpress functions in external js file

Discussion in 'JavaScript' started by alex05, Sep 7, 2010.

  1. #1
    Hello, i'm creating a wordpress template but i ran into a problem... i've created a contact page... with a contact form

    this is the form



    <form method="post" name="contatti" id="contatti" action="<?php bloginfo('template_url'); ?>/inviaemail.php"> 
    	<div id="contact_area">
    		<h2>Contattaci direttamente via email</h2> 
    	
    		<input type="text" name="name" id="name" class="form" value="Nome*" />
    		
    		<input type="text" name="email" id="email" class="form" value="e-Mail*" /> 
    		
    		<input type="text" name="sito" id="sito" class="form" value="Sito Web" /> 
    		
    		<textarea name="message" id="testo" class="form" rows="12" cols="" >Testo*</textarea>
    		
    		<div> 
    			<input type="submit" name="submit" id="invia" value="Invia"/>
    			<img src="<?php bloginfo('template_url'); ?>/images/load.gif" alt="load" id="load_img" />
    			<span id="result"></span>
    		</div>
    	</div> 
    </form> 
    PHP:


    This is a part of the ajax validation script from a js file into the theme template...

    else {
    			$('#load_img').fadeIn();
    			$.ajax({
    				type: 'post',
    				url: 'inviaemail.php',
    
    Code (markup):
    as you see, url : 'inviaemail.php' , is the file that send the email, but currently it try to load this file from the wordpress root, i need to load this file from the theme folder... wordpress got a php function to do this

    <?php bloginfo('template_directory'); ?>
    PHP:
    how can i make the js file to load inviaemail.php from the theme folder ?

    sorry for bad english...
     
    alex05, Sep 7, 2010 IP