• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ajax类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ajax的典型用法代码示例。如果您正苦于以下问题:PHP ajax类的具体用法?PHP ajax怎么用?PHP ajax使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ajax类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: Render

    public function Render($form = "", $response_location = "", $url = "", $args = "")
    {
        $errorMsg = '';
        $errors = FALSE;
        $Load = new Load();
        if (function_exists('is_empty') == FALSE) {
            // Load validate helper
            $Load->Helper('validate');
        }
        if (is_empty($form) == FALSE) {
            $this->form = $form;
        }
        if (is_empty($response_location) == FALSE) {
            $this->response_location = $response_location;
        }
        if (is_empty($url) == FALSE) {
            $this->url = $url;
        }
        if (is_empty($args) == FALSE) {
            $this->args = $args;
        }
        if (is_empty($this->form)) {
            $errorMsg .= ' form requerido :$obj-> Form("id-form")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->response_location)) {
            $errorMsg .= ' response_location requerido : $obj-> ResponseLocation("id-div-location")<br /> ';
            $errors = TRUE;
        }
        if (is_empty($this->url)) {
            $errorMsg .= ' url requerida : $obj-> Url("Controller/Action")<br /> ';
            $errors = TRUE;
        }
        if ($errors == TRUE) {
            echo 'Error:<br />' . $errorMsg;
            return FALSE;
        } else {
            // Crear respuesta
            $butonsCode = $this->RenderButtons();
            $params = 'form:' . $this->form . ';url:' . $this->url . ';args:' . $this->args . ';';
            $fx = new ajax('submit', $this->response_location, $params);
            $Result = ' <script type="text/javascript">
<!--
' . $butonsCode . '
$("#' . $this->form . '").validate({
	 submitHandler: function(form) {
		 ' . $fx->render() . '
		 return false;
	 },invalidHandler: function(form, validator){
      var errors = validator.numberOfInvalids();
      if (errors) { alert("Por favor, llena los campos obligatorios");}
	 }
});
//-->
</script>';
            return $Result;
        }
    }
开发者ID:mmendoza000,项目名称:freekore,代码行数:58,代码来源:ajax_submit.php


示例2: action_files

 public function action_files()
 {
     $files = array();
     $limit = arr::get($_GET, 'limit', 10);
     $offset = arr::get($_GET, 'offset', 0);
     $query = ORM::factory('File');
     if (arr::get($_GET, 'tags', false)) {
         $tags = arr::get($_GET, 'tags');
         if (arr::get($_GET, 'matchAll', false) == "true") {
             $tagsquery = DB::select('files_tags.file_id')->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->group_by('files_tags.file_id')->having(DB::expr('COUNT(files_tags.file_id)'), '=', count($tags))->execute();
             //die(var_dump($tagsquery));
         } else {
             $tagsquery = DB::select('files_tags.file_id')->distinct(true)->from('files_tags')->where('files_tags.tag_id', 'IN', $tags)->execute();
             //die(var_dump($tagsquery));
         }
         if ((bool) $tagsquery->count()) {
             $ids = array();
             foreach ($tagsquery as $q) {
                 $ids[] = arr::get($q, 'file_id');
                 //$files[] = ORM::factory('File', arr::get($q, 'file_id'))->info();
             }
             $query = $query->where('id', 'IN', $ids);
         } else {
             // Empty resultset
             ajax::success('ok', array('files' => array()));
         }
     }
     $query = $query->order_by('created', 'DESC')->limit($limit)->offset($offset)->find_all();
     if ((bool) $query->count()) {
         foreach ($query as $file) {
             $files[] = $file->info();
         }
     }
     ajax::success('ok', array('files' => $files));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:35,代码来源:Filebrowser.php


示例3: app_event_test_ajax1

function app_event_test_ajax1($page, $values)
{
    global $config;
    error_log("@app_event_test_ajax1 ==================");
    error_log(print_r($values, true));
    $a = array(array("caption" => "Test1", "value" => 90), array("caption" => "Test2", "value" => 91), array("caption" => "Test3", "value" => 92));
    ajax::sendJSON($a);
}
开发者ID:ctkjose,项目名称:reasgex,代码行数:8,代码来源:test_ui1.php


示例4: loadRoute

 public static function loadRoute()
 {
     $r = array('action' => 'default', 'values' => array(), 'method' => 'get', 'ajax' => false, 'view' => 'default');
     if (isset($_SERVER['REQUEST_METHOD'])) {
         $method = strtoupper($_SERVER['REQUEST_METHOD']);
     } else {
         $method = 'CLI';
     }
     if ($method == 'GET') {
         $r['values'] = $_GET;
         if (isset($_GET['_view'])) {
             $r['view'] = $_GET['_view'];
         }
     } elseif ($method == 'POST') {
         $r['values'] = $_POST;
         $r['method'] = 'post';
         if (isset($_POST['_view'])) {
             $r['view'] = $_POST['_view'];
         }
     } elseif ($method == 'CLI') {
         global $argv;
         $r['method'] = 'cli';
         $r['values'] = $argv;
     }
     $cfg_ajax_test = array(array('field' => 'ajax', 'data_type' => 'http', 'return_type' => 'any', 'action' => 'ajax'), array('field' => 'json', 'data_type' => 'http', 'return_type' => 'json', 'action' => 'json'), array('field' => 'jsonrpc', 'data_type' => 'jsonrpc', 'return_type' => 'json', 'action' => 'method'), array('field' => 'callback', 'data_type' => 'http', 'return_type' => 'jsonp', 'action' => 'method'), array('field' => 'jsonpCallback', 'data_type' => 'http', 'return_type' => 'jsonp', 'action' => 'method'));
     $ajax_type = null;
     if (isset($_REQUEST)) {
         foreach ($cfg_ajax_test as $test) {
             if (isset($_REQUEST[$test['field']])) {
                 $ajax_type = $test;
                 break;
             }
         }
     }
     if (!is_null($ajax_type)) {
         $r['ajax'] = true;
         $r['method'] = strtolower($method);
         $r['action'] = strtolower($_REQUEST[$ajax_type['action']]);
         $r['view'] = 'default';
         if ($ajax_type['data_type'] == 'http') {
             $r['values'] = $r['method'] == 'get' ? $_GET : $_POST;
         } elseif ($ajax_type['data_type'] == 'jsonrpc') {
             $r['values'] = json_decode(file_get_contents('php://input'));
             $r['action'] = $r['values']['method'];
         }
         if ($ajax_type['return_type'] == 'json' || $ajax_type['return_type'] == 'jsonp') {
             ajax::loadAJAX($r['values']);
             ajax::setType($ajax_type['return_type']);
         }
         //error_log(print_r($ajax_type, true));
     }
     if (isset($r['values']['a'])) {
         $r['action'] = strtolower($r['values']['a']);
     }
     return $r;
 }
开发者ID:ctkjose,项目名称:reasgex,代码行数:56,代码来源:rea.router.sg.php


示例5: initialize

 public function initialize()
 {
     $this->template = template::getInstance();
     if ($this->ajax) {
         $this->content = ajax::getInstance();
     } else {
         $this->content = index::getInstance();
     }
     $this->content->initialize();
 }
开发者ID:Ashaan,项目名称:phpgallery,代码行数:10,代码来源:engine.php


示例6: ajax

 function ajax()
 {
     global $user, $tenjin, $config_q;
     if ($_GET["vote_for"] == 1) {
         echo quote::vote_for(array("quote_id" => $_GET["q_id"], "user_id" => $user->data["user_id"], "ip" => $_SERVER['REMOTE_ADDR']));
     } else {
         if ($_GET["vote_against"] == 1) {
             echo quote::vote_against(array("quote_id" => $_GET["q_id"], "user_id" => $user->data["user_id"], "ip" => $_SERVER['REMOTE_ADDR']));
             /*
             $cv = new vote(array(
             	"quote_id" => $_GET["q_id"],
             	"user_id" => $user->data["user_id"],
             	"ip" => $_SERVER['REMOTE_ADDR'],
             ));
             $cv->vote_for();
             */
         }
     }
     if ($_GET["get_quote_for_facebook"] == 1) {
         echo ajax::get_quote_for_facebook($_GET["q_id"]);
     }
     if ($_GET["get_quotes_for_facebook"] == 1) {
         quote::get_random_quotes_for_facebook();
         die;
     }
     /* a strange kind of acl but ok
     			from here on you have to have permissions
     		*/
     if (!can_access()) {
         return true;
     }
     if ($_GET["dialog__add_quote"] == 1) {
         $tenjin_template = $config_q["template_dir"] . '/dialog__add_quote.phtml';
         $output = $tenjin->render($tenjin_template, $context);
         echo $output;
     } elseif ($_GET["get_tags"] == 1) {
         /*$this->format_tags_as_links(array(
         			"tags" => $_POST["tags"],
         		));*/
     } elseif ($_GET["format_tags_as_links"] == 1) {
         $tag = new tag();
         echo $tag->format_tags_as_links($_POST["tags"]);
     } elseif ($_GET["set_tags"] == 1) {
         $this->set_tags(array("tags" => $_POST["tags"], "q_id" => $_POST["q_id"]));
     } elseif ($_GET["get_quote"] == 1) {
         echo "get_quote";
     } elseif ($_GET["set_quote"] == 1) {
         echo "set_quote";
     } elseif ($_GET["get_category"] == 1) {
         $this->get_category(array("category_id" => $_POST["category_id"], "q_id" => $_POST["q_id"]));
     } elseif ($_GET["set_category"] == 1) {
         $this->set_category(array("category_id" => $_POST["category_id"], "q_id" => $_POST["q_id"]));
     }
 }
开发者ID:hkirsman,项目名称:tsitaat_com,代码行数:54,代码来源:ajax.php


示例7: autocomplete

 public function autocomplete()
 {
     $directories = array();
     $path_prefix = Input::instance()->get("q");
     foreach (glob("{$path_prefix}*") as $file) {
         if (is_dir($file) && !is_link($file)) {
             $directories[] = html::clean($file);
         }
     }
     ajax::response(implode("\n", $directories));
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:11,代码来源:admin_server_add.php


示例8: action_get

 public function action_get()
 {
     $visitors = ORM::factory('Visitor')->find_all();
     $varray = array();
     if ((bool) $visitors->count()) {
         foreach ($visitors as $visitor) {
             $varray[] = $visitor->info();
         }
     }
     ajax::success('ok', array('visitors' => $varray));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Currentvisitors.php


示例9: autocomplete

 public function autocomplete()
 {
     $tags = array();
     $tag_parts = explode(",", Input::instance()->get("term"));
     $tag_part = ltrim(end($tag_parts));
     $tag_list = ORM::factory("tag")->where("name", "LIKE", Database::escape_for_like($tag_part) . "%")->order_by("name", "ASC")->limit(100)->find_all();
     foreach ($tag_list as $tag) {
         $tags[] = (string) html::clean($tag->name);
     }
     ajax::response(json_encode($tags));
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:11,代码来源:tags.php


示例10: action_get

 public function action_get()
 {
     $errors = ORM::factory('Error')->order_by('time', 'DESC')->limit(10)->find_all();
     $errs = array();
     if ((bool) $errors->count()) {
         foreach ($errors as $e) {
             $errs[] = array('id' => $e->id, 'type' => $e->type, 'ip' => $e->ip, 'when' => date('d/m/Y H:i', $e->time), 'url' => $e->url);
         }
     }
     ajax::success('', array('errors' => $errs));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Errorpages.php


示例11: autocomplete

 public function autocomplete()
 {
     $directories = array();
     $path_prefix = Input::instance()->get("term");
     foreach (glob("{$path_prefix}*") as $file) {
         if (is_dir($file) && !is_link($file)) {
             $directories[] = (string) html::clean($file);
         }
     }
     ajax::response(json_encode($directories));
 }
开发者ID:HarriLu,项目名称:gallery3,代码行数:11,代码来源:admin_server_add.php


示例12: action_get

 public function action_get()
 {
     $content = ORM::factory('Content')->order_by('hits', 'DESC')->limit(10)->find_all();
     $contents = array();
     if ((bool) $content->count()) {
         foreach ($content as $c) {
             $contents[] = array('id' => $c->id, 'title' => $c->title, 'type' => $c->contenttype->display, 'hits' => $c->hits);
         }
     }
     ajax::success('', array('contents' => $contents));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:11,代码来源:Popularcontent.php


示例13: autocomplete

 public function autocomplete()
 {
     $tags = array();
     $tag_parts = explode(",", Input::instance()->get("q"));
     $limit = Input::instance()->get("limit");
     $tag_part = ltrim(end($tag_parts));
     $tag_list = ORM::factory("tag")->where("name", "LIKE", "{$tag_part}%")->order_by("name", "ASC")->limit($limit)->find_all();
     foreach ($tag_list as $tag) {
         $tags[] = html::clean($tag->name);
     }
     ajax::response(implode("\n", $tags));
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:12,代码来源:tags.php


示例14: action_message

 public function action_message()
 {
     $message = ORM::factory('Message', $this->request->param('id'));
     if (!$message->loaded()) {
         ajax::redirect('#/messages', __('The message wasn\'t found. Has it already been deleted?'));
     }
     $info = $message->info();
     if ($message->read == 0) {
         $message->set_read();
     }
     reply::ok(View::factory('Cms/Messages/message', array('message' => $message)), 'messages', array('viewModel' => 'viewModels/Messages/message', 'message' => $info));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:12,代码来源:Messages.php


示例15: BackendAjax

 protected static function BackendAjax()
 {
     $sort = type::post('array', 'array');
     $sql = sql::factory();
     $sql->setTable('metainfos');
     foreach ($sort as $s => $id) {
         $sql->setWhere('id=' . $id);
         $sql->addPost('sort', $s + 1);
         $sql->update();
     }
     ajax::addReturn(message::success(lang::get('save_sorting'), true));
 }
开发者ID:pasterntt,项目名称:dynao-CMS,代码行数:12,代码来源:metainfosPage.php


示例16: action_delete

 public function action_delete()
 {
     $role = ORM::factory('Role', arr::get($_POST, 'id'));
     if (!$role->loaded()) {
         ajax::error(__('Role not found. Has it been deleted already?'));
     }
     try {
         $role->delete();
         ajax::info(__('Deleted'));
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:13,代码来源:Roles.php


示例17: action_delete

 public function action_delete()
 {
     $vacation = ORM::factory('Vacation', arr::get($_POST, 'id', ''));
     if (!$vacation->loaded()) {
         ajax::error('Ferien blev ikke fundet. Er den allerede blevet slettet?');
     }
     try {
         $vacation->delete();
         ajax::success();
     } catch (exception $e) {
         ajax::error('Der opstod en fejl: ' . $e->getMessage());
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:13,代码来源:Vacations.php


示例18: action_toggleread

 public function action_toggleread()
 {
     $message = ORM::factory('Message', arr::get($_POST, 'id'));
     if (!$message->loaded()) {
         ajax::error(__('The message wasn\'t found. Has it already been deleted?'));
     }
     $message->read = arr::get($_POST, 'read', '0');
     try {
         $message->save();
         ajax::success();
     } catch (exception $e) {
         ajax::error(__('An uncaught error occurred: :error', array(':error' => $e->getMessage())));
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:Messages.php


示例19: action_getautosave

 public function action_getautosave()
 {
     if (!user::logged()) {
         ajax::error('You must be logged in');
     }
     $user = user::get();
     $autosave = ORM::factory('Page')->where('user_id', '=', $user->id)->where('type', '=', 'autosave')->find();
     $content = '';
     if ($autosave->loaded() && $autosave->content != '') {
         $content = $autosave->decode($autosave->content);
         $autosave->delete();
     }
     ajax::success('', array('content' => $content, 'md5' => md5($content)));
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:14,代码来源:Write.php


示例20: action_twitter

 public function action_twitter()
 {
     $redirect = '';
     try {
         $connection = new TwitterOAuth(arr::get($this->creds, 'key'), arr::get($this->creds, 'secret'));
         $tmp = $connection->getRequestToken('http://morningpages.net/auth/twittercallback');
         Session::instance()->set('twitter_oauth_token', arr::get($tmp, 'oauth_token', ''));
         Session::instance()->set('twitter_oauth_token_secret', arr::get($tmp, 'oauth_token_secret', ''));
         $redirect = $connection->getAuthorizeURL($tmp);
     } catch (exception $e) {
         ajax::error('Oh no! Something went wrong and we couldn\'t get a hold of Twitter! They might be too busy right now. You can either wait a bit and see if Twitter wakes up or use another way of logging in.');
         site::redirect();
     }
     site::redirect($redirect);
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:15,代码来源:Auth.php



注:本文中的ajax类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP album类代码示例发布时间:2022-05-23
下一篇:
PHP agente类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap