0

PHPファイルに投稿するajax関数があります。WordPress を使用しているので、get_url 関数を使用できるので、URL 全体をハードコーディングする必要はありません。

WordPress 関数は PHP であるため、ajax 投稿内で PHP を使用しようとしています。しかし、それはうまくいきません。何か案は ?それは可能ですか?

これは私が持っているものです。

$(document).ready(function(){

$('#submit').click(function(){

$.post('<?php echo get_template_directory_uri(); ?>/send.php', $("#mycontactform").serialize(),  function(response) {
$('#success').html(response);
//$('#success').hide('slow');
});
return false;

});

});

このような引用符内でphpエコーも試しました。

   $.post(' "<?php echo get_template_directory_uri(); ?>" /send.php' ....

他の方法でこのパスを取得します

http://mysite.com/%27%3C?php%20echo%20get_template_directory_uri();%20?%3E%27/send.php&email=&message=&name=&sent=1
4

1 に答える 1