在php while循环中调用jquery函数

时间:2015-04-15 11:47:37

标签: javascript php jquery

我需要从php while循环中调用jquery函数

我的代码

$msg_body                   =   "Test%20SMS";
while($mobList              =   mysql_fetch_array($resSet))
{
     $mobile                =   $mobList['mobile'];

     if($mobile)
     {
        ?>
        <script>
        $(document).ready(function() 
        {
            var mob         =   <?php echo $mobile;?>;
            var msgBody     =   <?php echo $msg_body;?> 
            var url         =   "http://example.com/abc.php?msg=TEXT&sendTo="+mob+"&message="+msgBody+"&method=sendMessage";
            $.get( url, function( data ) 
            {
                alert( "SMS SEND to : "+mob );
            });     
        }); 
        </script>
        <?php
     }
}

它正在运行一次,即如果有多个移动号码,它将执行一次并发送一个短信,

警报无效。

1 个答案:

答案 0 :(得分:0)

I used CURL, 
now its OK

if($scm_mobile)
    {
        $ch                 =   curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        $data               =   curl_exec($ch);
    }