开发者

How to tell an ajax request in ruby

开发者 https://www.devze.com 2023-01-16 11:22 出处:网络
IN PHP its like this but in Ruby is how if (isset($_SERVER[\'HTTP_X_REQUESTED_WITH\']) && $_SERVER[\'HTTP_X_REQUEST开发者_如何学运维ED_WITH\']==\"XMLHttpRequest\") {

IN PHP its like this but in Ruby is how

if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUEST开发者_如何学运维ED_WITH']=="XMLHttpRequest") {
    }else{
        // header("Location: " . base_url());
    }  


There's an xhr? method on the request object that you can use. So in your controller:

request.xhr?

will return true or false depending on whether the request was sent as an XMLHttpRequest.

0

精彩评论

暂无评论...
验证码 换一张
取 消