Table of Contents
回复内容:
Home Backend Development PHP Tutorial 现在作为一名自学前端开发的学生,对网站的前端与后台数据交互不懂,想学习ajax,很迷茫,不知从何学起?

现在作为一名自学前端开发的学生,对网站的前端与后台数据交互不懂,想学习ajax,很迷茫,不知从何学起?

Jun 17, 2016 am 08:31 AM

回复内容:

如果现在是2005年你说 Ajax 难学我表示理解,可现在是2014年了哇,Ajax 这么基础的概念还要扯上“迷茫”?
如果你翻不了墙,用不了 Google,我帮你找到一个学习的地方:AJAX 教程,一定要看! 会jquery吗,可以先从jquery的ajax入手,会比较简单。

ajax写在js脚本里,一般是获取表单的数据(value)然后传到php脚本进行处理,再接受返回的数据。jquery的写法是这样的:

js脚本
<span class="nx">$</span><span class="p">.</span><span class="nx">ajax</span><span class="p">({</span>
	<span class="nx">type</span><span class="o">:</span><span class="s1">'get'</span><span class="p">,</span> 
	<span class="nx">url</span><span class="o">:</span><span class="s1">'index.php'</span><span class="p">,</span>
	<span class="nx">data</span><span class="o">:</span><span class="p">{</span>
		<span class="nx">id</span><span class="o">:</span><span class="mi">1</span><span class="p">,</span>
		<span class="nx">num</span><span class="o">:</span><span class="mi">2</span>
		<span class="p">},</span>
	<span class="nx">datatype</span><span class="o">:</span><span class="s1">'json'</span><span class="p">,</span>
	<span class="nx">success</span><span class="o">:</span><span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">){</span>   <span class="c1">//这里的data是php返回的数据,参数是data固定不变</span>
		<span class="nx">alert</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
<span class="c1">//输出php脚本里'echo' 后面的数值,也就是3</span>
	<span class="p">}</span>
<span class="p">})</span>
Copy after login
如果你觉得你需要学习ajax的话,恐怕你更需要学习一样网站大概是怎么运行的。

最经典的前端面试题之一:当你点了百度的搜索按钮,到你看到搜索结果,这之间发生了一些什么事情。

可能对于这个面试问题的研究,能够让你明白更多的东西 假定你会写javascript
假定你知道什么是json
假定你会用怎么用javascript处理json

那么请还是先看
AJAX 教程
然后如果还是不明白,请简单入门php 在自己的电脑上建立一个服务器
PHP 教程(虽然对你来说可能有些困难,但是很有必要!)

然后我觉得 你可以先不要去 刨根问底,直接写 上述教程的例子

然后你可能懂了,也可能还不懂~ 没关系
如果还不懂
假定你不会写javascript
假定你不知道什么是json
假定你不会用javascript处理json

那么请重新学习javascript
在学习 javascript前强烈建议看下
HTML 系列教程
注意看html的基础部分
然后 先知道 如果没有ajax 我们怎么处理数据
然后 继续 循环这个环节~


最后不要在意上面那些人~ 他们是大牛 不了解我们小菜的世界 可以参考一下这个问题:

HTML、CSS、JavaScript、PHP、 MySQL 的学习顺序是什么? 请修改一下标题吧,你这水平应该还不算入了门。。。 加油! 请修改一下标题吧,你这水平应该还不算入了门。。。 我一朋友弄了一个前端交流群,大家有什么问题,就在那上面提问,互相学习,感觉还不错,学了不少知识!! 群号分享给你374694134 我觉得你需要学习的是http协议
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

How does session hijacking work and how can you mitigate it in PHP? How does session hijacking work and how can you mitigate it in PHP? Apr 06, 2025 am 12:02 AM

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

Describe the SOLID principles and how they apply to PHP development. Describe the SOLID principles and how they apply to PHP development. Apr 03, 2025 am 12:04 AM

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? How to debug CLI mode in PHPStorm? Apr 01, 2025 pm 02:57 PM

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set permissions of unixsocket after system restart? How to automatically set permissions of unixsocket after system restart? Mar 31, 2025 pm 11:54 PM

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Framework Security Features: Protecting against vulnerabilities. Framework Security Features: Protecting against vulnerabilities. Mar 28, 2025 pm 05:11 PM

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

See all articles