Ajax variable to php


Ajax variable to php

嘿:)如何获取变量测试,发送文件路径字符串而不是回显"$test"。我想运行一个 php 函数,它可以看到文件路径并相应地运行。

这是我到目前为止所拥有的。

<script type="text/javascript">
    $(document).ready(function(){
        $(".link-text").click(function(){
            var $contentPanelId = jQuery(this).attr("id");
            var $test= ("Images/Pictures/materials/" + $contentPanelId + "/");
            $.ajax({
                type: 'POST',
                url: 'php_functions.php?name=$test',
                success: function(path) 
                {
                     $( '#somthing' ).append( path );
                }
            }); 
   });
});
</script>

谢谢!

<script type = "text/javascript" >
    $(document).ready(function () {
        $(".link-text").click(function () {
            var $contentPanelId = jQuery(this).attr("id");
            var $test = ("Images/Pictures/materials/" + $contentPanelId + "/");
            $.ajax({
                type: 'POST',
                url: 'php_functions.php',
                data: {
                    name: $test
                },
                success: function (path) {
                    $('#somthing').append(path);
                }
            });
        });
    });
</script>