求思路:juqery+thinkphp的问答系统解决思路
求思路:juqery+thinkphp的问答系统
大概的要求就是点击左侧的问题,右侧出现该问题的所有的回答.问题我已经从数据库中调用.
我的想法
1.是先从数据库总查询出该问题的答案,然后写下来,然后通过jquery显示出来 (或者写入)
2.还是通过jjquery取得该问题的id,传真给thinkphp,查询数据库后,输出?()
3.是不是要用到ajax?
应该选择哪个,大概如何实现
因为我只看了w3c的jquery教程,所有有点不知道从何下手,新手,描述的有点不清楚.
------解决思路----------------------
你说的第2点就要用到ajax
至于1还是2好,取决于问题的数量
只有几十个干脆直接查出答案,通过js点击改变右边div内容
如果问题很多,还带翻页,就要ajax查了
jquery:
$.get(url?id=123, function(data){alert(data)})
thinkphp:
$this->ajaxReturn($data);
------解决思路----------------------
前台JQ修改CSS
后台一次查询一页的数量+分页AJAX查询
------解决思路----------------------
$(document).ready只能给页面刚开始的按钮绑定事件
你给点赞按钮加一个class:js_up,然后加一个id="123"
然后jquery里写:$('.js_up').live('click', function(){ajax提交点赞,id就是按钮的id属性})

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

ThinkPHP installation steps: Prepare PHP, Composer, and MySQL environments. Create projects using Composer. Install the ThinkPHP framework and dependencies. Configure database connection. Generate application code. Launch the application and visit http://localhost:8000.

Using Ajax to obtain variables from PHP methods is a common scenario in web development. Through Ajax, the page can be dynamically obtained without refreshing the data. In this article, we will introduce how to use Ajax to get variables from PHP methods, and provide specific code examples. First, we need to write a PHP file to handle the Ajax request and return the required variables. Here is sample code for a simple PHP file getData.php:

ThinkPHP is a high-performance PHP framework with advantages such as caching mechanism, code optimization, parallel processing and database optimization. Official performance tests show that it can handle more than 10,000 requests per second and is widely used in large-scale websites and enterprise systems such as JD.com and Ctrip in actual applications.

Build an autocomplete suggestion engine using PHP and Ajax: Server-side script: handles Ajax requests and returns suggestions (autocomplete.php). Client script: Send Ajax request and display suggestions (autocomplete.js). Practical case: Include script in HTML page and specify search-input element identifier.
