简体   繁体   English

如何使用ajax和codeigniter解决400(错误请求)错误

[英]how to solve 400 (Bad Request) error with ajax and codeigniter

I am getting a 400 (Bad Request) error with ajax and codeigniter 我收到Ajax和Codeigniter的400(错误请求)错误

this is my ajax call 这是我的ajax电话

$.ajax({
            type: "POST",
            url: '<?php echo base_url(); ?>query/sensor/'+ test + / + past  + / + id + / + port + / + device,

            success: function(res) {
            if (res)
            {

                console.log("res"+res);
                    }
            }
            });


      }

is it a proper ajax url? 这是一个合适的Ajax网址吗?

  • First Make sure you get variables values test, past .... 首先请确保您获得变量值测试,过去....
  • You can change url: 'query/sensor/'+ test + / + past + / + id + / + port + / + device, 您可以更改网址:“查询/传感器/” +测试+ / +过去的++ / ++ id + / +端口++ / +设备,

    With this url: 使用此网址:

url: 'query/sensor/'+ test +'/' + past + '/' + id + '/' + port + '/' + device, 网址:“查询/传感器/” +测试+“ /” +过去+“ /” + id +“ /” +端口+“ /” +设备,

regards :) 问候 :)

$.post(
"your_url", 
{
  value1: value1,
  value2: value2,
  value3: value3,

}, 
function(result){

  alert(result);
});

Use this post method 使用此发布方法

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM