phpMv -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
Loading...
Searching...
No Matches
AjaxCall.php
Go to the documentation of this file.
1<?php
2namespace Ajax\service;
3
5
6class AjaxCall {
7
8 private $method;
9
10 private $parameters;
11
12 public function __construct($method, $parameters) {
13 $this->method = $method;
14 $this->parameters = $parameters;
15 }
16
17 public function compile(JsUtils $js = null) {
18 if ($js === null)
19 return;
20 $params = "{}";
21 $stopPropagation = true;
22 $preventDefault = true;
23 $method = "get";
24 $this->parameters["immediatly"] = false;
25 extract($this->parameters);
26 $result = $this->_eventPreparing($preventDefault, $stopPropagation);
27 switch ($this->method) {
28 case "get":
29 $result .= $js->getDeferred($url, $responseElement, $this->parameters);
30 break;
31 case "post":
32 $result .= $js->postDeferred($url, $params, $responseElement, $this->parameters);
33 break;
34 case "postForm":
35 $result .= $js->postFormDeferred($url, $form, $responseElement, $this->parameters);
36 break;
37 case "json":
38 $result .= $js->jsonDeferred($url, $method, $this->parameters);
39 break;
40 case "jsonArray":
41 $result .= $js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters);
42 break;
43 default:
44 $result .= $js->ajaxDeferred($this->method, $url, $responseElement, $this->parameters);
45 break;
46 }
47 return $result;
48 }
49
50 protected function _eventPreparing($preventDefault, $stopPropagation) {
51 $result = "";
52 if ($preventDefault === true) {
54 }
55 if ($stopPropagation === true) {
57 }
58 return $result;
59 }
60
61 public function getMethod() {
62 return $this->method;
63 }
64
65 public function setMethod($method) {
66 $this->method = $method;
67 return $this;
68 }
69
70 public function getParameters() {
71 return $this->parameters;
72 }
73
74 public function setParameters($parameters) {
75 $this->parameters = $parameters;
76 return $this;
77 }
78}
JQuery PHP library.
Definition JsUtils.php:23
_eventPreparing($preventDefault, $stopPropagation)
Definition AjaxCall.php:50
setParameters($parameters)
Definition AjaxCall.php:74
__construct($method, $parameters)
Definition AjaxCall.php:12
compile(JsUtils $js=null)
Definition AjaxCall.php:17