简体   繁体   中英

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

I am getting a 400 (Bad Request) error with ajax and codeigniter

this is my ajax call

$.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?

  • First Make sure you get variables values test, past ....
  • You can change url: 'query/sensor/'+ test + / + past + / + id + / + port + / + device,

    With this url:

url: 'query/sensor/'+ test +'/' + past + '/' + id + '/' + port + '/' + device,

regards :)

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

}, 
function(result){

  alert(result);
});

Use this post method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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