Simple jQuery, PHP and JSONP example?

后端 未结 7 2264
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 16:36

I am facing the same-origin policy problem, and by researching the subject, I found that the best way for my particular project would be to use JSONP to do cross-origin requ

7条回答
  •  误落风尘
    2020-11-22 17:01

    $.ajax({
    
            type:     "GET",
            url: '',
            data: {name: mail},
            dataType: "jsonp",
            jsonp: 'callback',
            jsonpCallback: 'chekEmailTaken',
            success: function(msg){
        }
    });
    return true;
    

    In controller:

    public function ajax_checkjp(){
    $checkType = $_GET['name'];
    echo $_GET['callback']. '(' . json_encode($result) . ');';  
    }
    

提交回复
热议问题