$.post("ajax_save.php",{str:str,rid:rid,act:"trans",dept_name:dept_name,dept_id:dept_id},function(data){
if(data.substring(0,16)=="SUCCESSSAVEFIRST"){
alert("保存成功");location.reload();
}else if(data.substring(0,12)=="SUCCESSSAVED"){
alert("保存成功");location.reload();
}else
alert(data);
});
我使用post方法传数据到ajax_save.php,如果成功就返回相应的值,并alert相应的文字。我在本地测试的时候是可以使用的,但是我上传到服务器后,使用ie就无法正常传值了,但是也没有弹出任何的错误提示,是怎么回事了?ajaxiejavascript服务器
if(data.substring(0,16)=="SUCCESSSAVEFIRST"){
alert("保存成功");location.reload();
}else if(data.substring(0,12)=="SUCCESSSAVED"){
alert("保存成功");location.reload();
}else
alert(data);
});
我使用post方法传数据到ajax_save.php,如果成功就返回相应的值,并alert相应的文字。我在本地测试的时候是可以使用的,但是我上传到服务器后,使用ie就无法正常传值了,但是也没有弹出任何的错误提示,是怎么回事了?ajaxiejavascript服务器
2.按下F12,打开开发者工具
3.启动调试模式
4.触发您的这段代码运行
5.切换到网络选项卡,查看是否有这个异步的网络请求
6.如果没有,请检查发起异步的代码是否真的执行了
7.如果执行了,请查看服务器返回的报文有没有问题
8.如果没有问题,请查看服务器返回的报头的Content-Type是否有问题对于第8点,如果您的后端有手动改动Content-Type报头的话,请检查字符间的空格有没有出错,因为我被这个坑过。
var dept_name=$("#dept option:selected").text();
$("#sub").click(function(){
// var dept_id=$("#dept_id").val(); var str="";
rid=$("#rid").val();
alert(rid);
if(dept_id==0){
alert("请选择部门");return false;
}
$("input[name='"+rid+"']:checked").each(function(){
str+=$(this).val()+",";
}); if(str==""){
alert("请选择节点");return false;
} $.post("ajax_save.php",{str:str,rid:rid,act:"trans",dept_name:dept_name,dept_id:dept_id},function(data){
if(data.substring(0,16)=="SUCCESSSAVEFIRST"){
alert("保存成功");location.reload();
}else if(data.substring(0,12)=="SUCCESSSAVED"){
alert("保存成功");location.reload();
}else
alert(data);
}); });我整段代码是这样的,报错是报rid=$("#rid").val();,对象不支持此属性或方法