javascript 怎么通知php处理数据,然后返回结果,javascript继续处理,然后html显示?
回复讨论(解决方案)
貌似可以用ajax吧
貌似可以用ajax吧
不用ajax的话,要怎么弄!
还有ajax的要怎么用?
这种功能只能用ajax 去下个jquery的手册
$.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});
这种功能只能用ajax 去下个jquery的手册
$.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});
这种功能只能用ajax 去下个jquery的手册
$.ajax({ type: "POST", url: "some.php", data: "name=John&location=Boston", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});
给你个例子
<script> <br /> <br /> var sp = $("#wScratchPad").wScratchPad({ <br /> scratchDown: function(e, percent){show(e, percent);}, <br /> scratchMove: function(e, percent){show(e, percent);}, <br /> scratchUp: function(e, percent){show(e, percent);} <br /> }); <br /> <br /> var myImage='<?php echo $myImage?>'; <br /> <br /> sp.wScratchPad('width', '115'); <br /> sp.wScratchPad('height', '33'); <br /> sp.wScratchPad('size', '5'); <br /> sp.wScratchPad('image',myImage); <br /> //sp.wScratchPad('image2', './images/2.png'); //覆盖在上面的图片 <br /> sp.wScratchPad('cursor', './cursors/coin.png'); <br /> sp.wScratchPad('reset'); <br /> <br /> function show(e,percent) <br /> { <br /> if(percent > 70) <br /> { <br /> <br /> sp.wScratchPad('clear'); <br /> <br /> window.location.href="dealggl.php?num="+'<?php echo $iRandNum?>'; <br /> } <br /> } <br /> <br /> </script>
就是上面判断70的地方,我要给dealggl.php一些数据,写入数据库,然后处理完,回到本页面;用ajax的话要怎么弄
$.ajax({ type: "GET", url: "dealggl.php", data: "num="+'<?php echo $iRandNum?>', success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});
$.ajax({ type: "GET", url: "dealggl.php", data: "num="+'<?php echo $iRandNum?>', success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});
<script> <br /> function click2() <br /> { <br /> alert("wwww"); <br /> $.ajax({ <br /> type: "GET", <br /> url: "del.php", <br /> data: "num=3", <br /> success: function(msg){ <br /> alert( "Data Saved: " + msg ); <br /> //成功html显示结果 <br /> } <br /> }); <br /> } <br /> </script>
del.php
echo $_GET["num"];
?>
一直都没成功
<html><head><title></title><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script type="text/javascript">function click2(){alert("wwww");$.ajax({ type: "GET", url: "del.php", data: "num=3", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});}</script></head><body><input type="button" onclick="click2()" value="test"></body></html>
需要加载jquery文件啊 你都没加载怎么能成功呢
可以不用ajax <script></script>
我一般用ajax 再联合js 这样做起来很快。
<html><head><title></title><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script type="text/javascript">function click2(){alert("wwww");$.ajax({ type: "GET", url: "del.php", data: "num=3", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});}</script></head><body><input type="button" onclick="click2()" value="test"></body></html>
需要加载jquery文件啊 你都没加载怎么能成功呢
哦,折腾下可以了。但是我要传回多个值怎么办?要用拼接,在分割的方法吗?能多个传参回来吗
可以不用ajax <script></script>
这个怎么用?就填个url?那参数怎么传回来?
<html><head><title></title><script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script><script type="text/javascript">function click2(){alert("wwww");$.ajax({ type: "GET", url: "del.php", data: "num=3", success: function(msg){ alert( "Data Saved: " + msg ); //成功html显示结果 }});}</script></head><body><input type="button" onclick="click2()" value="test"></body></html>
需要加载jquery文件啊 你都没加载怎么能成功呢
哦,折腾下可以了。但是我要传回多个值怎么办?要用拼接,在分割的方法吗?能多个传参回来吗
传多个值,也有很多方法 比如拼接字符串等等
然后,我强烈推荐使用json格式
由于ajax返回的都是字符串,所以可以在PHP中把你需要传回的多项数值放进数组, 使用php的json_encode方法将数组转换为json字符串.
js接收到以后使用eval方法将字符串解析进数组对象
然后就可以方便的使用了
可以不用ajax <script></script>
这个怎么用?就填个url?那参数怎么传回来?
url里边包含参数咯 不过你php里边要返回 document.write();
可以不用ajax <script></script>
这个怎么用?就填个url?那参数怎么传回来?
url里边包含参数咯 不过你php里边要返回 document.write();
没太懂?我要传参数到del.php,del.php处理完数据,传回参数,这个<script></script>东东,怎么拿出参数,接着分析呢?
这个网上很多呀,就是前后台交互问题 ,传输数格式一般用json 比较方面,多百度下吧
这个网上很多呀,就是前后台交互问题 ,传输数格式一般用json 比较方面,多百度下吧
一般人都叫多百度下多谷歌下!高手不想帮忙,可以围观,没必要进来说没用的废话!
建议LZ看看JQ AJAX方法,应该是你想要的。
建议LZ看看JQ AJAX方法,应该是你想要的。
jq中得ajax跟js里面的ajax有什么区别?
最简单的也就是ajax了,用jquery封装好的 $.ajax 真的很省事
如果你用原生的ajax就代码就要写一堆!

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

In PHP, use the clone keyword to create a copy of the object and customize the cloning behavior through the \_\_clone magic method. 1. Use the clone keyword to make a shallow copy, cloning the object's properties but not the object's properties. 2. The \_\_clone method can deeply copy nested objects to avoid shallow copying problems. 3. Pay attention to avoid circular references and performance problems in cloning, and optimize cloning operations to improve efficiency.

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor