Ajax.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847
  1. <?php
  2. namespace ZN\ViewObjects\Jquery\Helpers;
  3. use ZN\ViewObjects\JqueryTrait;
  4. class Ajax
  5. {
  6. //----------------------------------------------------------------------------------------------------
  7. //
  8. // Yazar : Ozan UYKUN <ozanbote@windowslive.com> | <ozanbote@gmail.com>
  9. // Site : www.zntr.net
  10. // Lisans : The MIT License
  11. // Telif Hakkı: Copyright (c) 2012-2016, zntr.net
  12. //
  13. //----------------------------------------------------------------------------------------------------
  14. use JqueryTrait;
  15. //----------------------------------------------------------------------------------------------------
  16. // Call Method
  17. //----------------------------------------------------------------------------------------------------
  18. //
  19. // __call()
  20. //
  21. //----------------------------------------------------------------------------------------------------
  22. use \CallUndefinedMethodTrait;
  23. /*
  24. * Fonksiyon blokları
  25. *
  26. * success, error, complete...
  27. *
  28. * @var array
  29. */
  30. protected $functions = [];
  31. /*
  32. * Ayar blokları
  33. *
  34. * url, method, data...
  35. *
  36. * @var array
  37. */
  38. protected $sets = [];
  39. /* Dönüş fonksiyon blokları
  40. *
  41. * .done, .always, .then .fail
  42. *
  43. * @var array
  44. */
  45. protected $callbacks = [];
  46. /******************************************************************************************
  47. * URL *
  48. *******************************************************************************************
  49. | Genel Kullanım: Url parametresini ayarlamak için kullanılır. |
  50. @param string $url
  51. @return $this
  52. | |
  53. ******************************************************************************************/
  54. public function url($url = '')
  55. {
  56. if( ! is_string($url) )
  57. {
  58. \Errors::set('Error', 'stringParameter', '1.(url)');
  59. return $this;
  60. }
  61. // Veri bir url içermiyorsa siteUrl yöntemi ile url'ye dönüştürülür.
  62. if( ! isUrl($url) )
  63. {
  64. $url = siteUrl($url);
  65. }
  66. $this->sets['url'] = "\turl:\"$url\",".EOL;
  67. return $this;
  68. }
  69. /******************************************************************************************
  70. * DATA *
  71. *******************************************************************************************
  72. | Genel Kullanım: Gönderilen Veri parametresini ayarlamak için kullanılır. |
  73. @param string $data
  74. @return $this
  75. | |
  76. ******************************************************************************************/
  77. public function data($data = '')
  78. {
  79. if( ! is_scalar($data) )
  80. {
  81. \Errors::set('Error', 'valueParameter', '1.(data)');
  82. return $this;
  83. }
  84. $this->sets['data'] = "\tdata:$data,".EOL;
  85. return $this;
  86. }
  87. /******************************************************************************************
  88. * HEADERS *
  89. *******************************************************************************************
  90. | Genel Kullanım: Başlıklar parametresini ayarlamak için kullanılır. |
  91. @param string $headers
  92. @return $this
  93. | |
  94. ******************************************************************************************/
  95. public function headers($headers = '')
  96. {
  97. if( ! is_scalar($headers) )
  98. {
  99. \Errors::set('Error', 'valueParameter', '1.(headers)');
  100. return $this;
  101. }
  102. $this->sets['headers'] = "\theaders:$headers,".EOL;
  103. return $this;
  104. }
  105. /******************************************************************************************
  106. * IF MODIFIED *
  107. *******************************************************************************************
  108. | Genel Kullanım: If Modified parametresini ayarlamak için kullanılır. |
  109. @param bool $ifModified true
  110. @return $this
  111. | |
  112. ******************************************************************************************/
  113. public function ifModified($ifModified = true)
  114. {
  115. if( ! is_scalar($ifModified) )
  116. {
  117. \Errors::set('Error', 'valueParameter', '1.(isModified)');
  118. return $this;
  119. }
  120. // Mantıklasal veri metinsel veriye dönüştürülüyor.
  121. $ifModified = $this->_boolToStr($ifModified);
  122. $this->sets['ifModified'] = "\tifModified:$ifModified,".EOL;
  123. return $this;
  124. }
  125. /******************************************************************************************
  126. * IS LOCAL *
  127. *******************************************************************************************
  128. | Genel Kullanım: Is Local parametresini ayarlamak için kullanılır. |
  129. @param bool $isLocal true
  130. @return $this
  131. | |
  132. ******************************************************************************************/
  133. public function isLocal($isLocal = true)
  134. {
  135. if( ! is_scalar($isLocal) )
  136. {
  137. \Errors::set('Error', 'valueParameter', '1.(isLocal)');
  138. return $this;
  139. }
  140. $isLocal = $this->_boolToStr($isLocal);
  141. $this->sets['isLocal'] = "\tisLocal:$isLocal,".EOL;
  142. return $this;
  143. }
  144. /******************************************************************************************
  145. * MIME TYPE *
  146. *******************************************************************************************
  147. | Genel Kullanım: MIME Type parametresini ayarlamak için kullanılır. |
  148. @param bool $mimeType true
  149. @return $this
  150. | |
  151. ******************************************************************************************/
  152. public function mimeType($mimeType = true)
  153. {
  154. if( ! is_scalar($mimeType) )
  155. {
  156. \Errors::set('Error', 'valueParameter', 'mimeType');
  157. return $this;
  158. }
  159. $mimeType = $this->_boolToStr($mimeType);
  160. $this->sets['mimeType'] = "\tmimeType:$mimeType,".EOL;
  161. return $this;
  162. }
  163. /******************************************************************************************
  164. * JSONP *
  165. *******************************************************************************************
  166. | Genel Kullanım: Jsonp parametresini ayarlamak için kullanılır. |
  167. @param string/bool $jsonp
  168. @return $this
  169. | |
  170. ******************************************************************************************/
  171. public function jsonp($jsonp = '')
  172. {
  173. if( is_bool($jsonp) )
  174. {
  175. $jsonp = $this->_boolToStr($jsonp);
  176. }
  177. elseif( is_string($jsonp) )
  178. {
  179. $jsonp = "\"$jsonp\"";
  180. }
  181. else
  182. {
  183. return $this;
  184. }
  185. $this->sets['jsonp'] = "\tjsonp:$jsonp,".EOL;
  186. return $this;
  187. }
  188. /******************************************************************************************
  189. * JSONP CALLBACK *
  190. *******************************************************************************************
  191. | Genel Kullanım: Jsonp Callback parametresini ayarlamak için kullanılır. |
  192. @param string $jsonpCallback
  193. @return $this
  194. | |
  195. ******************************************************************************************/
  196. public function jsonpCallback($jsonpCallback = '')
  197. {
  198. if( ! is_scalar($jsonpCallback) )
  199. {
  200. \Errors::set('Error', 'valueParameter', 'jsonpCallback');
  201. return $this;
  202. }
  203. if( $this->_isFunc($jsonpCallback) === false )
  204. {
  205. $jsonpCallback = "\"$jsonpCallback\"";
  206. }
  207. $this->sets['jsonpCallback'] = "\tjsonpCallback:$jsonpCallback,".EOL;
  208. return $this;
  209. }
  210. /******************************************************************************************
  211. * DATA TYPE *
  212. *******************************************************************************************
  213. | Genel Kullanım: Data Type parametresini ayarlamak için kullanılır. |
  214. @param string $type
  215. @return $this
  216. | |
  217. ******************************************************************************************/
  218. public function dataType($type = '')
  219. {
  220. if( ! is_string($type) )
  221. {
  222. \Errors::set('Error', 'stringParameter', 'type');
  223. return $this;
  224. }
  225. $this->sets['type'] = "\tdataType:\"$type\",".EOL;
  226. return $this;
  227. }
  228. // PASSWORD Property -------------------------------------------------------
  229. // password data
  230. // password:string
  231. public function password($password = '')
  232. {
  233. if( ! is_string($password) )
  234. {
  235. \Errors::set('Error', 'stringParameter', 'password');
  236. return $this;
  237. }
  238. $this->sets['password'] = "\tpassword:\"$password\",".EOL;
  239. return $this;
  240. }
  241. // USERNAME Property -------------------------------------------------------
  242. // username data
  243. // username:string
  244. public function username($username = '')
  245. {
  246. if( ! is_string($username) )
  247. {
  248. \Errors::set('Error', 'stringParameter', 'username');
  249. return $this;
  250. }
  251. $this->sets['username'] = "\tusername:\"$username\",".EOL;
  252. return $this;
  253. }
  254. // METHOD/TYPE Property ----------------------------------------------------
  255. // type() = method()
  256. // type data
  257. // type:string : post, get ...
  258. public function method($method = 'post')
  259. {
  260. if( ! is_string($method) )
  261. {
  262. \Errors::set('Error', 'stringParameter', 'method');
  263. return $this;
  264. }
  265. $this->sets['method'] = "\tmethod:\"$method\",".EOL;
  266. return $this;
  267. }
  268. // METHOD/TYPE Property ----------------------------------------------------
  269. // type() = method()
  270. // type data
  271. // type:string : post, get ...
  272. public function type($method = 'post')
  273. {
  274. $this->method($method);
  275. return $this;
  276. }
  277. // SCRIPT CHARSET Property -------------------------------------------------------
  278. // scriptCharset data
  279. // scriptCharset:string
  280. public function scriptCharset($scriptCharset = 'utf-8')
  281. {
  282. if( ! isCharset($scriptCharset) )
  283. {
  284. \Errors::set('Error', 'charsetParameter', 'scriptCharset');
  285. return $this;
  286. }
  287. $this->sets['scriptCharset'] = "\tscriptCharset:\"$scriptCharset\",".EOL;
  288. return $this;
  289. }
  290. // TRADITIONAL Property -------------------------------------------------------
  291. // traditional data
  292. // traditional:bool: true or false
  293. public function traditional($traditional = true)
  294. {
  295. if( ! is_scalar($traditional) )
  296. {
  297. \Errors::set('Error', 'valueParameter', 'traditional');
  298. return $this;
  299. }
  300. $traditional = $this->_boolToStr($traditional);
  301. $this->sets['traditional'] = "\ttraditional:$traditional,".EOL;
  302. return $this;
  303. }
  304. // PROCESS DATA Property -------------------------------------------------------
  305. // processData data
  306. // processData:bool: true or false
  307. public function processData($processData = true)
  308. {
  309. if( ! is_scalar($processData) )
  310. {
  311. \Errors::set('Error', 'valueParameter', 'processData');
  312. return $this;
  313. }
  314. $processData = $this->_boolToStr($processData);
  315. $this->sets['processData'] = "\tprocessData:$processData,".EOL;
  316. return $this;
  317. }
  318. // CACHE Property -------------------------------------------------------
  319. // cache data
  320. // cache:bool: true or false
  321. public function cache($cache = true)
  322. {
  323. if( ! is_scalar($cache) )
  324. {
  325. \Errors::set('Error', 'valueParameter', 'cache');
  326. return $this;
  327. }
  328. $cache = $this->_boolToStr($cache);
  329. $this->sets['cache'] = "\tcache:$cache,".EOL;
  330. return $this;
  331. }
  332. // XHR FIELDS Property -------------------------------------------------------
  333. // xhrFields data
  334. // xhrFields:string
  335. public function xhrFields($xhrFields = '')
  336. {
  337. if( ! is_string($xhrFields) )
  338. {
  339. \Errors::set('Error', 'stringParameter', 'xhrFields');
  340. return $this;
  341. }
  342. $this->sets['xhrFields'] = "\txhrFields:$xhrFields,".EOL;
  343. return $this;
  344. }
  345. // CONTEXT Property -------------------------------------------------------
  346. // context data
  347. // context:plain object
  348. public function context($context = '')
  349. {
  350. if( ! is_scalar($context) )
  351. {
  352. \Errors::set('Error', 'valueParameter', 'context');
  353. return $this;
  354. }
  355. $this->sets['context'] = "\tcontext:$context,".EOL;
  356. return $this;
  357. }
  358. // ACCEPTS Property -------------------------------------------------------
  359. // accepts data
  360. // accepts:plain object
  361. public function accepts($accepts = '')
  362. {
  363. if( ! is_string($accepts) )
  364. {
  365. \Errors::set('Error', 'stringParameter', 'accepts');
  366. return $this;
  367. }
  368. $this->sets['accepts'] = "\taccepts:$accepts,".EOL;
  369. return $this;
  370. }
  371. // CONTENTS Property -------------------------------------------------------
  372. // contents data
  373. // contents:plain object
  374. public function contents($contents = '')
  375. {
  376. if( ! is_string($contents) )
  377. {
  378. \Errors::set('Error', 'stringParameter', 'contents');
  379. return $this;
  380. }
  381. $this->sets['contents'] = "\tcontents:$contents,".EOL;
  382. return $this;
  383. }
  384. // ASYNC Property -------------------------------------------------------
  385. // async data
  386. // async:bool: true or false
  387. public function async($async = true)
  388. {
  389. if( ! is_scalar($async) )
  390. {
  391. \Errors::set('Error', 'valueParameter', 'async');
  392. return $this;
  393. }
  394. $async = $this->_boolToStr($async);
  395. $this->sets['async'] = "\tasync:$async,".EOL;
  396. return $this;
  397. }
  398. // CROSS DOMAIN Property -------------------------------------------------------
  399. // crossDomain data
  400. // crossDomain:bool: true or false
  401. public function crossDomain($crossDomain = true)
  402. {
  403. if( ! is_scalar($crossDomain) )
  404. {
  405. \Errors::set('Error', 'valueParameter', 'crossDomain');
  406. return $this;
  407. }
  408. $crossDomain = $this->_boolToStr($crossDomain);
  409. $this->sets['crossDomain'] = "\tcrossDomain:$crossDomain,".EOL;
  410. return $this;
  411. }
  412. // TIMEOUT Property -------------------------------------------------------
  413. // timeout data
  414. // timeout:numeric
  415. public function timeout($timeout = '')
  416. {
  417. if( ! is_scalar($timeout) )
  418. {
  419. \Errors::set('Error', 'valueParameter', 'timeout');
  420. return $this;
  421. }
  422. $this->sets['timeout'] = "\ttimeout:$timeout,".EOL;
  423. return $this;
  424. }
  425. // GLOBAL Property -------------------------------------------------------
  426. // global data
  427. // global:bool : true or false
  428. // global is keywords so global is name globals
  429. public function globals($globals = true)
  430. {
  431. if( ! is_scalar($globals) )
  432. {
  433. \Errors::set('Error', 'valueParameter', 'globals');
  434. return $this;
  435. }
  436. $globals = $this->_boolToStr($globals);
  437. $this->sets['globals'] = "\tglobal:$globals,".EOL;
  438. return $this;
  439. }
  440. // CONTENT TYPE Property -------------------------------------------------------
  441. // contentType data
  442. // contentType:bool or string
  443. // is bool : true or false
  444. // is_string: 'application/x-www-form-urlencoded; charset=UTF-8'
  445. public function contentType($contentType = 'application/x-www-form-urlencoded; charset=UTF-8')
  446. {
  447. if( is_bool($contentType) )
  448. {
  449. $contentType = $this->_boolToStr($contentType);
  450. }
  451. elseif( is_string($contentType) )
  452. {
  453. $contentType = "\"$contentType\"";
  454. }
  455. else
  456. {
  457. \Errors::set('Error', 'valueParameter', 'contentType');
  458. return $this;
  459. }
  460. $this->sets['contentType'] = "\tcontentType:$contentType,".EOL;
  461. return $this;
  462. }
  463. protected function _object($name, $codes = [])
  464. {
  465. if( ! is_array($codes) )
  466. {
  467. \Errors::set('Error', 'arrayParameter', 'codes');
  468. return $this;
  469. }
  470. $eol = EOL;
  471. $statusCode = $eol."\t$name:".$eol."\t{";
  472. if( ! empty($codes) )
  473. {
  474. foreach( $codes as $code => $value )
  475. {
  476. $param = '';
  477. if(strstr($value, '->'))
  478. {
  479. $params = explode('->', $value);
  480. $param = $params[0];
  481. $value = $params[1];
  482. }
  483. $statusCode .= $eol."\t\t$code:function($param)".$eol."\t\t{".$eol."\t\t\t$value".$eol."\t\t},".$eol;
  484. }
  485. $statusCode = trim(trim($statusCode), ',').$eol;
  486. }
  487. $statusCode .= "\t}";
  488. $this->functions[$name] = $eol."\t".$statusCode;
  489. }
  490. // STATUS CODE Property -------------------------------------------------------
  491. // statusCode data
  492. // statusCode:array
  493. // array(404 => 'alert(404);', 403 => 'alert(403);')
  494. // To use parameters ::::: param1, param2->codes... ::::: function(param1, param2){codes}
  495. // -> parameters and codes is seperators
  496. // array(404 => 'data->alert(data);', 403 => 'data->alert(data);')
  497. public function statusCode($codes = [])
  498. {
  499. $this->_object('statusCode', $codes);
  500. return $this;
  501. }
  502. // CONVERTERS Property -------------------------------------------------------
  503. // converters data
  504. // converters:array
  505. // To use parameters ::::: param1, param2->codes... ::::: function(param1, param2){codes}
  506. // -> parameters and codes is seperators
  507. // array('C1' => 'alert('c1');', C2 => 'param1, param2->alert('c2');')
  508. public function converters($codes = [])
  509. {
  510. $this->_object('converters', $codes);
  511. return $this;
  512. }
  513. protected function _functions($name, $params, $codes)
  514. {
  515. if( ! is_string($params) || ! is_string($codes) )
  516. {
  517. \Errors::set('Error', 'stringParameter', 'params & codes');
  518. return $this;
  519. }
  520. $eol = EOL;
  521. $this->functions[$name] = $eol."\t$name:function($params)".$eol."\t{".$eol."\t\t$codes".$eol."\t}";
  522. }
  523. // SUCCESS FUNCTION Property -------------------------------------------------------
  524. // success data
  525. // success: 2 Parameters
  526. // string @params : 'param1, param2'
  527. // string @success: 'alert("example")'
  528. public function success($params = 'e', $success = '')
  529. {
  530. $this->_functions('success', $params, $success);
  531. return $this;
  532. }
  533. // ERROR FUNCTION Property -------------------------------------------------------
  534. // error data
  535. // error: 2 Parameters
  536. // string @params : 'param1, param2'
  537. // string @error : 'alert("example")'
  538. public function error($params = 'e', $error = '')
  539. {
  540. $this->_functions('error', $params, $error);
  541. return $this;
  542. }
  543. // COMPLETE FUNCTION Property -------------------------------------------------------
  544. // complete data
  545. // complete: 2 Parameters
  546. // string @params : 'param1, param2'
  547. // string @complete : 'alert("example")'
  548. public function complete($params = 'e', $complete = '')
  549. {
  550. $this->_functions('complete', $params, $complete);
  551. return $this;
  552. }
  553. // BEFORE SEND FUNCTION Property -------------------------------------------------------
  554. // beforeSend data
  555. // beforeSend: 2 Parameters
  556. // string @params : 'param1, param2'
  557. // string @before_send : 'alert("example")'
  558. public function beforeSend($params = 'e', $beforeSend = '')
  559. {
  560. $this->_functions('beforeSend', $params, $beforeSend);
  561. return $this;
  562. }
  563. // DATA FILTER FUNCTION Property -------------------------------------------------------
  564. // dataFilter data
  565. // dataFilter: 2 Parameters
  566. // string @params : 'param1, param2'
  567. // string @data_filter : 'alert("example")'
  568. public function dataFilter($params = 'e', $dataFilter = '')
  569. {
  570. $this->_functions('dataFilter', $params, $dataFilter);
  571. return $this;
  572. }
  573. protected function _callbacks($name, $params, $codes)
  574. {
  575. if( ! ( is_string($params) || is_string($codes) ) )
  576. {
  577. return $this;
  578. }
  579. $eol = EOL;
  580. $this->callbacks[$name] = $eol.".$name(function($params)".$eol."{".$eol."\t$codes".$eol."})";
  581. }
  582. // DONE CALLBACK FUNCTION Property -------------------------------------------------------
  583. // done data
  584. // done: 2 Parameters
  585. // string @params : 'param1, param2'
  586. // string @done : 'alert("example")'
  587. public function done($params = 'e', $done = '')
  588. {
  589. $this->_callbacks('done', $params, $done);
  590. return $this;
  591. }
  592. // FAIL CALLBACK FUNCTION Property -------------------------------------------------------
  593. // fail data
  594. // fail: 2 Parameters
  595. // string @params : 'param1, param2'
  596. // string @fail : 'alert("example")'
  597. public function fail($params = 'e', $fail = '')
  598. {
  599. $this->_callbacks('fail', $params, $fail);
  600. return $this;
  601. }
  602. // ALWAYS CALLBACK FUNCTION Property -------------------------------------------------------
  603. // always data
  604. // always: 2 Parameters
  605. // string @params : 'param1, param2'
  606. // string @always : 'alert("example")'
  607. public function always($params = 'e', $always = '')
  608. {
  609. $this->_callbacks('always', $params, $always);
  610. return $this;
  611. }
  612. // THEN CALLBACK FUNCTION Property -------------------------------------------------------
  613. // then data
  614. // then: 2 Parameters
  615. // string @params : 'param1, param2'
  616. // string @then : 'alert("example")'
  617. public function then($params = 'e', $then = '')
  618. {
  619. $this->_callbacks('then', $params, $then);
  620. return $this;
  621. }
  622. // Complementary method of operation
  623. // Optional Use Parameters
  624. // [string @url]) => url() method instead of the alternative
  625. // [string @data]) => data() method instead of the alternative
  626. public function send($url = '', $data = '')
  627. {
  628. if( ! is_string($url) || ! is_string($data) )
  629. {
  630. return \Errors::set('Error', 'stringParameter', 'url & data');
  631. }
  632. if( ! empty($url) )
  633. {
  634. $this->url($url);
  635. }
  636. if( ! empty($data) )
  637. {
  638. $this->data($data);
  639. }
  640. if( ! isset($this->sets['method']) )
  641. {
  642. $this->method('post');
  643. }
  644. $eol = EOL;
  645. $ajax = '';
  646. if( ! empty($this->sets) ) foreach( $this->sets as $val )
  647. {
  648. $ajax .= $val;
  649. }
  650. if( ! empty($this->functions) ) foreach( $this->functions as $val )
  651. {
  652. $ajax .= "\t$val,";
  653. }
  654. $ajax = rtrim(trim($ajax), ',');
  655. $callbacks = '';
  656. if( ! empty($this->callbacks) )
  657. {
  658. foreach( $this->callbacks as $val )
  659. {
  660. $callbacks .= $val;
  661. }
  662. $callbacks .= ";".$eol;
  663. }
  664. else
  665. {
  666. $callbacks = ";".$eol;
  667. }
  668. $ajax = $this->_tag($eol."$.ajax".$eol."({".$eol."$ajax".$eol."})$callbacks");
  669. $this->_defaultVariable();
  670. return $ajax;
  671. }
  672. // Complementary method of operation
  673. // Optional Use Parameters
  674. // [string @url]) => url() method instead of the alternative
  675. // [string @data]) => data() method instead of the alternative
  676. public function create($url = '', $data = '')
  677. {
  678. return $this->send($url, $data);
  679. }
  680. // DEFAULT VARIABLES
  681. protected function _defaultVariable()
  682. {
  683. $this->functions = [];
  684. $this->sets = [];
  685. $this->callbacks = [];
  686. }
  687. }