我似乎无法将任何数据发送到服务器。甚至在其他一些页面上我也能做到。唯一的区别是,我使用的是这种垂直格式的文件上传。一切都在chrome中效果很好。
错误在哪里?
<script>
$( document ).ready(function() {
$("#addnewadform").submit(function(e){
e.preventDefault();
$.ajax({
cache:false,
url: "/call/insert-standart-add.call.php", //URL IS CORRECT
type: "post", // this is OK too
data: {submitStandartPost:'im sending the submit button value'}, //this is a super-simplified version of what i want the server to recieve
contentType: 'multipart/form-data',//i have tried a ton of different values for this
processData: false, //think this should be false for file uploads
success: function(data){
console.log(data);
if(data!==''){
console.log(data);
}else{
console.log("nothing was sent");
}
}
});
});
});
</script>
服务器没有收到任何信息,但是脚本本身正在被调用。
if(isset($_POST['submitStandartPost'])){
}else{
echo 'no input';
}
错误可能与文件上传无关。我试图删除文件上载和enctype ='multipar / bal bla bal'。就是行不通。没有记录错误
我有时讨厌HTML ...
反正。避免此问题的最佳方法是以清晰的跨浏览器方式使用,因为它不可靠,所以不要使用$ _POST ['submit']按钮。
因此,例如,不要这样做:
if(isset($_POST['submit'])){
//do my form logic here
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句