Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php ajaxjquerypost问题_Php_Jquery_Ajax - Fatal编程技术网

Php ajaxjquerypost问题

Php ajaxjquerypost问题,php,jquery,ajax,Php,Jquery,Ajax,有一段代码使用ajax$.post函数向php文件发送一个名称,然后php文件会对其执行一些操作,我遇到了一些问题。我认为问题出在ajax代码中,因为我发现POST值从未到达$\u POST数组,即$\u POST数组未设置。然而,我不认为这两个方面都有任何语法错误,所以我不明白为什么它不起作用 这是jQuery if ($(e.target).hasClass('shootNames')) { var shootName = $(e.target).at

有一段代码使用ajax$.post函数向php文件发送一个名称,然后php文件会对其执行一些操作,我遇到了一些问题。我认为问题出在ajax代码中,因为我发现POST值从未到达$\u POST数组,即$\u POST数组未设置。然而,我不认为这两个方面都有任何语法错误,所以我不明白为什么它不起作用

这是jQuery

    if ($(e.target).hasClass('shootNames')) {
                var shootName = $(e.target).attr('id'); 
                var par = $('#' + shootName).parent().attr("id"); 

                $.post("displayImages.php", {shoot: shootName}); //the information I would like to send

                $('#' + par).load("displayImages.php").off('click', $('#' + par));
            }//end if hasClass 
以及php的相关部分

if (isset($_POST['shoot'])) {
$shootname = $_POST['shoot'][0]; //pick out just the first member of the $_POST array 
$filepath = "images/u/$foo/$shootname";
$f->FilesAsImages($filepath);
}//end if
谢谢你的帮助

您在$.post调用中点击了displayImages.php一次,它应该会返回您的图像,但是您在那里没有成功处理程序,因此它对结果没有任何影响。然后,您再次使用.load点击displayImages.php,并且没有向它传递任何信息,因此它不会像预期的那样执行任何操作。将成功处理程序添加到$.post调用中并在其中执行工作,将满足您的需要

有关更多信息,请参阅$.post文档:

示例代码:

if ($(e.target).hasClass('shootNames')) {
    var shootName = $(e.target).attr('id');
    var par = $('#' + shootName).parent().attr("id");

    $.post("displayImages.php", {
        shoot: shootName
    }, function(data, textStatus, jqXHR) { 
        // this is the success function and the 3 arguments it gives you, remove the 2nd/3rd if you don't use them
        $('#' + par).html(data).off('click', $('#' + par)); 
    }); 
}
试着改变一下

 $.post("displayImages.php", {shoot: shootName}); //the information I would like to send
对此

 $.post("displayImages.php", {'shoot[]': shootName}); //the information I would like to send
资料来源:

您能使用浏览器开发工具检查ajax请求吗。。。在那里,你应该能够看到发送给Serv嘿的PARAM是什么,所以我只是尝试了,比如:$.PasDePixIsIph.php,{Stu:SooNoT},函数{$+PAR,LoopDeStudioSimult.php。OFF点击,$+PAR;};它仍然给我同样的结果。