返回服务器响应并显示在同一页面中

时间:2012-12-13 09:14:05

标签: php ajax post curl

我一直试图将这个问题运行数周。

我想要的是将数据发送到那里显示的服务器并返回服务器响应,但我从响应中得到的只是url但是url没有执行它只会显示在响应var

<?php
class send
{

    public $username;
    public $password;
    public $destination;
    public $sender;
    public $msg;
    public $type;
    public $dlr;
    public $url;

    function __construct()
    {
    }

    function send_sms(){
        $posturl = 'http://121.241.242.114:8080/bulksms/bulksms?';
        $number = $this->destination;

        $msg = urlencode($this->msg);
        $type='0';
        $dlr='1';
        $url='';
        $posturl = $posturl."source=".$this->sender."&username=".$this->username."&password=".$this->password."&type=".$type."&dlr=".$dlr."&destination=".$number."&message=".$msg;
        $ch = curl_init(); 
        curl_setopt($ch, CURLOPT_URL, $posturl); 
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
        curl_setopt($ch, CURLOPT_POST, true);
        $response = curl_exec($ch); 
        return $posturl;
    }

}
?>

1 个答案:

答案 0 :(得分:0)

return $response; //and not $posturl