这是我的jQuery .load函数。 我想要做的是使用jQuery传递的值运行php函数。 我想我只是不明白如何将值与jQuery传递给服务器。 我可能需要使用.get或.post吗? 请指教。
$(document).ready(function(){ $("#scotland").click(function() { $("#Main").load('thumbs.php #Main', $path=./scotland); }); });
jQuery脚本所针对的php div。
通常在早期出现这种问题,不知道如何与客户端语言(JavaScript)交互到服务器端(PHP)。 但是我们走吧!
对于页面“thumbs.php”接收参数,您必须通过GET或POST发送数据。
使用Javascript:
$(document).ready(function(){ $("#scotland").click(function() { $("#Main").load('thumbs.php', {'path': 'scotland'}); }); });
thumbs.php
"; } } closedir($dir_handle); } ?>
如果数据未传递,则jquery中的方法.load()使用GET请求类型。 在我们的例子中,我传递数据({‘path’:’scotland’}),因此请求的类型为POST。
有用的链接 :
我希望我有所帮助=]
将jQuery脚本更改为:
$(document).ready(function(){ $("#scotland").click(function() { $("#Main").load('thumbs.php #Main', {'func': 'thumbnailload', 'path': './scotland'}); }); });
并将PHP代码更改为:
"; } } closedir($dir_handle); } thumbnailload($path); ?>
对于ref: http : //api.jquery.com/load/
以上就是jQuery教程分享使用jQuery .load()将参数传递给php函数并调用它相关内容,想了解更多jQuery开发(异常处理)及jQuery教程关注计算机技术网(www.ctvol.com)!)。
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/jquerytutorial/532422.html