本文整理汇总了PHP中ajax函数的典型用法代码示例。如果您正苦于以下问题:PHP ajax函数的具体用法?PHP ajax怎么用?PHP ajax使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ajax函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMyList
function getMyList()
{
$this->load->model('muser');
$this->muser->check() or noRights();
$res = $this->db->where("id in (SELECT yid FROM yue_people WHERE uid=" . UID . ")", null, FALSE)->select("id,uid,(SELECT name FROM user WHERE user.id=uid) authorName,(SELECT avatar FROM user WHERE user.id=uid) authorAvatar,title,time")->get('yue')->result_array();
ajax(0, '', $res);
}
示例2: action
private static function action()
{
//禁止使用模块检测
if (in_array(MODULE, C('http.deny_module'))) {
throw new Exception("模块禁止访问");
}
$class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
//控制器不存在
if (!class_exists($class)) {
throw new Exception("{$class} 不存在");
}
$controller = Route::$app->make($class, TRUE);
//执行控制器中间件
\Middleware::performControllerMiddleware();
//执行动作
try {
$reflection = new ReflectionMethod($controller, ACTION);
if ($reflection->isPublic()) {
//执行动作
if ($result = call_user_func_array([$controller, ACTION], self::$routeArgs)) {
if (IS_AJAX && is_array($result)) {
ajax($result);
} else {
echo $result;
}
}
} else {
throw new ReflectionException('请求地址不存在');
}
} catch (ReflectionException $e) {
$action = new ReflectionMethod($controller, '__call');
$action->invokeArgs($controller, [ACTION, '']);
}
}
示例3: overlay2
function overlay2()
{
$ajax = ajax();
$rules = array('rules' => array('a[name]' => array('required' => true, 'minlength' => 5), 'a[last_name]' => array('required' => true, 'minlength' => 5)), 'messages' => array('a[name]' => array('required' => 'Please enter your name'), 'a[last_name]' => array('required' => 'Enter your last name')));
$overlay = $ajax->overlayContent(file_get_contents('resources/html/test_form.html'));
$overlay->validate('button1', 'ajax.php?overlay_validation/form', $rules);
}
示例4: dl
function dl($option)
{
$ajax = ajax();
$review = $this->remoteCookie('http://sourceforge.net/', 'http://sourceforge.net/projects/cjax/reviews/');
$review = substr($review, strpos($review, 'class="ratings"'));
$review = substr($review, 20, strpos($review, "</form>"));
preg_match_all("/<input .+ name=['|\"]([^'\"]+)/", $review, $data);
$data = $data[1];
preg_match_all("/<input .+ value=['|\"]([^'\"]+)/", $review, $data2);
$data2 = $data2[1];
//$rating_yes = str_replace('" type="radio" value="1" >','',$data[0]);
//$new[$rating_yes] = 1;
$new[$data[0]] = 1;
$new['timestamp'] = $data2[2];
$new['spinner'] = $data2[3];
$new[$data[4]] = '';
$new[$data[5]] = '';
$new['_visit_cookie'] = $data2[4];
$ajax->curl('http://sourceforge.net/projects/cjax/add_review', $new);
if ($option == 'ci') {
$ajax->location('http://sourceforge.net/projects/cjax/files/CodeIgnater/AJAXFW_4CI_5.1-Stable.zip/download');
} else {
$ajax->location('http://sourceforge.net/projects/cjax/files/CJAXFW_5.1-Stable.zip/download');
}
}
示例5: upload
function upload()
{
$ajax = ajax();
$plugin = $ajax->uploadify();
$exts = $plugin->get('exts');
$target = $plugin->get('target');
$targetFolder = $target;
if (!empty($_FILES)) {
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetFile = rtrim($targetFolder, '/') . '/' . $_FILES['Filedata']['name'];
// Validate the file type
if ($exts) {
$fileTypes = $exts;
// File extensions
} else {
$fileTypes = array('jpg', 'jpeg', 'gif', 'png');
// File extensions
}
$fileParts = pathinfo($_FILES['Filedata']['name']);
if (in_array($fileParts['extension'], $fileTypes)) {
echo $targetFile;
if (move_uploaded_file($tempFile, $targetFile)) {
echo '1';
} else {
echo 'error!';
}
} else {
echo 'Invalid file type.';
}
}
}
示例6: feedback
function feedback()
{
$this->load->model('muser');
$this->muser->check() or noRights();
$data = $this->input->post('content', TRUE) or errInput();
$this->db->insert('feedback', ['content' => $data, 'uid' => UID]) ? ajax() : busy();
}
示例7: action
private static function action()
{
//禁止使用模块检测
if (in_array(MODULE, C('http.deny_module'))) {
throw new Exception("模块禁止访问");
}
$class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
//控制器不存在
if (!class_exists($class)) {
throw new Exception("{$class} 不存在");
}
$controller = Route::$app->make($class, true);
//执行控制器中间件
Middleware::controller();
//执行动作
try {
$result = App::callMethod($controller, ACTION);
if (IS_AJAX && is_array($result)) {
ajax($result);
} else {
echo $result;
}
} catch (ReflectionException $e) {
$action = new ReflectionMethod($controller, '__call');
$action->invokeArgs($controller, [ACTION, '']);
}
}
示例8: newVersion
function newVersion()
{
if ($data = $this->input->post(NULL, true)) {
$this->db->insert('version', $data) ? ajax() : busy();
} else {
$this->load->view('version');
}
}
示例9: commentList
function commentList()
{
$id = (int) $this->input->post('id');
$page = (int) $this->input->post('page', FALSE, 0);
$count = (int) $this->input->post('count', FALSE, 10);
$data = $this->db->select('id,content,time,(SELECT avatar FROM user WHERE user.id=uid) authorAvatar,(SELECT name FROM user WHERE user.id=uid) authorName')->where('bid', $id)->limit($count, $count * $page)->order_by('id', 'desc')->get('bcomment')->result_array();
ajax(0, '', $data);
}
示例10: tryAgain
function tryAgain()
{
usleep(1000);
$ajax = ajax();
$_cache = $ajax->get('cjax_x_cache');
echo "//trying\n";
return $_cache;
}
示例11: test2
/**
* ajax.php?test/test2
*
* Here we are testing out the javascript library.
*
* Note: the library it is not meant to be included in ajax controllers - but in front-controllers,
* it is being used here for the sake of simplicity in testing.
*/
function test2()
{
$ajax = ajax();
$ajax->update('response', 'Cjax Works');
$ajax->append('#response', '<br /><br />version: ' . $ajax->version);
$ajax->success('Cjax was successfully installed.', 5);
//see application/views/test2.php
$this->load->view('test2');
}
示例12: onLoad
function onLoad($button_id, $post_url, $rules = array(), $import_js = false)
{
$ajax = ajax();
$this->callback($ajax->click($button_id, $ajax->form($post_url)));
if ($import_js) {
$this->import('jquery.validate.min.js');
}
$this->rules = $rules;
}
示例13: getKeywords
public function getKeywords()
{
$key = q('post.key');
if ($key) {
$content = Db::table('rule_keyword')->where("content LIKE '%{$key}%'")->where('siteid', SITEID)->where('status', 1)->get();
} else {
$content = Db::table('rule_keyword')->where('siteid', v('site.siteid'))->where('status', 1)->limit(10)->get();
}
ajax($content);
}
示例14: onLoad
function onLoad($btn_id = null, $target_directory = null, $options = array())
{
if (is_array($btn_id) && !$options) {
$options = $btn_id;
$btn_id = null;
if (isset($options['dir'])) {
$target_directory = $options['dir'];
}
}
$ajax = ajax();
foreach ($options as $k => $v) {
$this->{$k} = $v;
}
if (isset($options['before'])) {
$this->set('a', $options);
}
if ($ajax->config->uploader_dir) {
$target_directory = $ajax->config->uploader_dir;
}
if (!$target_directory) {
$target_directory = './';
}
if (!is_writable($target_directory)) {
return $ajax->warning("Cjax Upload: Directory '{$target_directory}' is not writable, , aborting..", 5);
}
if (!isset($options['text'])) {
$options['text'] = 'Uploading File(s)...';
}
if (!isset($options['ext'])) {
$options['ext'] = array('jpg', 'jpeg', 'gif', 'png');
}
if (!isset($options['files_require'])) {
$options['files_require'] = true;
}
if (!isset($options['form_id'])) {
$options['form_id'] = null;
}
$ajax->text = $options['text'];
$target = rtrim($target_directory, '/') . '/';
if (!isset($options['url'])) {
$options['url'] = null;
}
if (!isset($options['target'])) {
$options['target'] = $target;
}
$ajax->save('upload_options', $options);
if (!$btn_id || is_array($btn_id)) {
$xml = $ajax->form($options['url'], $options['form_id']);
} else {
$xml = $ajax->Exec($btn_id, $ajax->form($options['url'], $options['form_id']));
}
$this->options = $options;
$this->callback($xml);
}
示例15: post
function post($files)
{
$ajax = ajax();
//files listed under 'files' array are files that were successfully uploaded
if ($files) {
$ajax->wait(2, false);
$ajax->alert("Controller Response:" . print_r($files, 1));
}
//uncoment to see the response on the screen
//$ajax->overlayContent($ajax->dialog("<pre>".print_r($_REQUEST,1)."</pre>","Controller Response: upload_file/post "));
}