Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. // in a js "class"
  2.  
  3. this.ajaxError=function(response)
  4. {
  5. alert('AJAX error!'+response)
  6. }
  7.  
  8. this.ajax=function(url,type,success,error)
  9. {
  10. $.ajax({
  11. url: url,
  12. type:type,
  13. success: success,
  14. error: error
  15. });
  16. }
  17.  
  18. this.showMessage=function(response)
  19. {
  20. alert(JSON.parse(response));
  21. }
  22.  
  23. this.open=function()
  24. {
  25. alert("1");
  26. this.ajax('/message/open/173','text',this.showMessage,this.ajaxError);
  27. }
  28.  
  29.  
  30. //php in vew/open.ctp
  31. <?php
  32. ?>
  33.  
  34.  
  35. //messagecontroller.php
  36.  
  37. public function open($stream_id)
  38. {
  39. /*$result = $this->Stream->find('first', array(
  40. 'conditions' => array('Stream.id' => $stream_id
  41. )
  42. ));
  43. echo json_encode($result);*/
  44. echo "id:".$stream_id;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement