Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 未发送jquery ajax响应_Php_Jquery - Fatal编程技术网

Php 未发送jquery ajax响应

Php 未发送jquery ajax响应,php,jquery,Php,Jquery,我有一个表单,它使用post方法将其内容提交到php脚本,脚本返回一个xml文件。我发现在检测错误方面存在问题,我在firefox控制台中没有看到任何错误,这是jquery代码: $(document).ready(function() { $('form').submit( function() { //alert('bonjour'); var pr= $('#prenom').val(); var te=$('#tech').val(); var sk=$('#skills').val(

我有一个表单,它使用post方法将其内容提交到
php
脚本,脚本返回一个
xml
文件。我发现在检测错误方面存在问题,我在firefox控制台中没有看到任何错误,这是jquery代码:

$(document).ready(function() {
$('form').submit( function() {
//alert('bonjour');
var pr= $('#prenom').val(); 
var te=$('#tech').val();
var sk=$('#skills').val() ; 
$("#form1").ajaxError(function(){
alert("An error occured!");
});
$.ajax({
url: "filter.php",
type: "POST",
data: { prenom: pr , tech: te , skills: sk },

dataType: "xml",
success: function(data) {
//alert(data);
$(data).find('collaborateur').each(function(){

var id = $(this).attr('id');
var urlPhoto = $(this).find('urlphoto').text();
var nb_cv = $(this).find('nb_cv').text();
var poste = $(this).find('poste').text();
var nb_ann_exp = $(this).find('nb_ann_exp').text();
var identite = $(this).find('identite').text();
var nom = $(this).find('nom').text();
var prenom = $(this).find('prenom').text();
$('<div class="items" id="link_'+id+'"></div>').html('<a href="'+urlPhoto+'"  

style="float:left">'+nom+'</a><span>'+nom+' '+prenom+'</span>').appendTo('#result');

}

);
//$('#result').html(data);
alert('Load was performed.');
},
fail: function(){alert ('fail');}
});
});
}); 
过滤函数

function filter($pren, $tech, $comp)
{global $connection;
$tab = array();
$query="SELECT  DISTINCT c.id_c,`prenom`,`nom`,`nb_exp`,`ident`,`poste` , NomPhoto,   

nb_cv  FROM `collaborateur` c, techno_mai m , competence_cle cc  where( prenom like     

'$pren'  or (m.lib_tech like '$tech' and m.id_c =c.id_c )  or (cc.id_c = c.id_c and   

cc.lib_cc like '$comp')) ";

$c12=mysql_query($query, $connection)or die(mysql_error());
$i =0;
while($fil= mysql_fetch_array($c12))
{
$tab[$i]['prenom'] =$fil['prenom'];
$tab[$i]['nom']= $fil['nom'];
$tab[$i]['nb_exp']=$fil['nb_exp'];
$tab[$i]['ident']=$fil['ident'];
$tab[$i]['poste']=$fil['poste'];
$tab[$i]['NomPhoto']=$fil['NomPhoto'];
$tab[$i]['nb_cv']=$fil['nb_cv'];
$tab[$i]['nom']=$fil['nom'];
$tab[$i]['prenom']=$fil['prenom'];
$i++;
}
return $tab;

}
我在一个没有
ajax
的表单中测试了
php
代码,它呈现了一个正确的
xml
文件。 不带ajax的服务器输出(xml文件)

<collaborateurs>
<collaborateur id="0">
<nom>semi</nom>
<prenom>troc</prenom>
<nb_cv>0</nb_cv>
<poste>tech</poste>
<nb_ann_exp>12</nb_ann_exp>
<identite>dis</identite>
</collaborateur>
<collaborateur id="1">
<nom>tarek</nom>
<prenom>fellah</prenom>
<nb_cv>0</nb_cv>
<poste>dev</poste>
<nb_ann_exp>2</nb_ann_exp>
<identite>dev web</identite>
</collaborateur>
<collaborateur id="2">
<nom>ahmed</nom>
<prenom>hamza</prenom>
<nb_cv>0</nb_cv>
<poste>dev web</poste>
<nb_ann_exp>0</nb_ann_exp>
<identite>dev web</identite>
</collaborateur>
</collaborateurs>

半决赛
特罗克
0
技术人员
12
数字化信息系统
塔瑞克
伙计
0
发展
2.
开发网站
艾哈迈德
哈姆扎
0
开发网站
0
开发网站
提前感谢。

您正在设置

data: { prenom: pr , te: tech , sk: skills },
但后来又重新审判

 $tab = filter($_POST['prenom'], $_POST['tech'], $_POST['skills']);
应该是

data: { prenom: pr , tech: te , skills: sk},
你正在设置

data: { prenom: pr , te: tech , sk: skills },
但后来又重新审判

 $tab = filter($_POST['prenom'], $_POST['tech'], $_POST['skills']);
应该是

data: { prenom: pr , tech: te , skills: sk},

//警报(数据);未注释时,输出是什么?我看到您对警报进行了注释以及打印,因此您测试了服务器通信是否正确。。。它起作用了吗?@Onheiron现在ajaxError事件已处理,当未注释的内容未发生时,“发生错误”消息显示为mithunsatheesh OK,您能否使用正确的数据和ajaxError处理编辑问题中的代码?还有你的filter()函数,你能给我们看看吗?现在没有ajax,服务器会输出什么?您对所使用的路径持肯定态度吗?例如,如果您用echo“hello”替换所有php,并且所有成功:使用函数(data){alert(data);}它是否在客户端显示“hello”?//alert(data);未注释时,输出是什么?我看到您对警报进行了注释以及打印,因此您测试了服务器通信是否正确。。。它起作用了吗?@Onheiron现在ajaxError事件已处理,当未注释的内容未发生时,“发生错误”消息显示为mithunsatheesh OK,您能否使用正确的数据和ajaxError处理编辑问题中的代码?还有你的filter()函数,你能给我们看看吗?现在没有ajax,服务器会输出什么?您对所使用的路径持肯定态度吗?例如,如果您用echo“hello”替换所有php,并且全部成功:使用函数(data){alert(data);}它是否在客户端上显示“hello”?现在它可以工作了,但我用click事件更改了提交事件,有人能告诉我问题的根源吗?如果您在提交时绑定,则无论如何都会触发提交默认事件,从而执行表单操作(或者,如果未设置任何操作,则只需“刷新”页面)。您可以通过页面URL中显示的?来判断页面的行为。为了在提交事件上执行自定义操作,您必须防止这种行为。因此,如果您更喜欢使用提交为事件,只需将提交时触发的函数设置为:函数(e){e.preventDefault;…此处的代码…}现在可以工作了,但我用click事件更改了submit事件,有人能告诉我问题的根源吗?如果在submit上绑定,则无论如何都会触发submit默认事件,从而执行表单操作(如果未设置任何操作,则只是“刷新”页面)。您可以通过页面URL中出现的?来判断它的行为。为了在提交事件上执行自定义操作,您必须防止这种行为。因此,如果您更喜欢使用提交为事件,只需将提交时触发的函数设置为:函数(e){e.preventDefault;…此处的代码…}