How to call external url in jquery?

前端 未结 7 1677
再見小時候
再見小時候 2020-11-28 10:44

I am trying to put comments on Facebook wall using jquery.

But my ajax call not alowing external url .

can anyone explain how can we use external url with jq

7条回答
  •  我在风中等你
    2020-11-28 10:57

    Follow the below simple steps you will able to get the result

    Step 1- Create one internal function getDetailFromExternal in your back end. step 2- In that function call the external url by using cUrl like below function

     function getDetailFromExternal($p1,$p2) {
    
            $url = "http://request url with parameters";
            $ch = curl_init();
            curl_setopt_array($ch, array(
                CURLOPT_URL => $url,
                CURLOPT_RETURNTRANSFER => true            
            ));
    
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            $output = curl_exec($ch);
            curl_close($ch);
            echo $output;
            exit;
        }
    

    Step 3- Call that internal function from your front end by using javascript/jquery Ajax.

提交回复
热议问题