A
A
alex5e2014-04-02 01:20:27
JavaScript
alex5e, 2014-04-02 01:20:27

Ajax request to vk API in yii controller - what's the problem?

I am doing an ajax request to post to a group in VK. The entry is published, but the post_id does not return.

<?php
public function actionVip()
{
$message = "тестовая запись";
 ?>
            <script type="text/javascript">
              $.ajax({
                url: "https://api.vk.com/method/wall.post?owner_id=-69173875&from_group=1&message=<?php echo(urldecode($message)); ?>&access_token=$token&v=3.0",
              //dataType: "json",
              type: "POST",
              success: function (data){
                  var result = jQuery.parseJSON(data); 
                   if(result)
                        alert('Сообщение отправлено! ID сообщения: ' + result.post_id);
                       else
                           alert('Ошибка'+ result.post_id);
              },
             

              });
            </script> <?php
$this->renderPartial('_ajaxVipValidate', $data="1", false, false);
 }
?>


success is not executed. If success is replaced with complete, then a window is displayed, but result.post_id is undefined. Firebug gives 200 OK. But the answer is empty. What could be the problem? And one more question. Is it possible to make ajax request in a controller action with a response in a more concise way?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-04-02
Protko @Fesor

WAT?

K
Kirill Arutyunov, 2014-04-02
@arutyunov

PHP brain?
Have you heard of views? What is MVC, do you know?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question