点击事件加载php文件,javascript – 如何在“onclick”事件期间加载外部php文件?...

我试图在选项卡上加载谷歌地图点击以缩短页面加载.我在控制台中没有收到任何错误.只需清空div< div class =“gmap”>< / div>,这应该如下所示:< div class =“gmap”>< iframe style =“border:none;” width =“350px”height =“150px”src =“http://maps.google.com/maps?myadress”>< / iframe>< / div>.似乎脚本不是在点击时执行的.

我究竟做错了什么?我需要提一下我还在学习.

这是地图脚本的工作方式:JSFIDDLE

map.php

define( '_JEXEC', 1 );

define( 'JPATH_BASE', realpath(dirname(__FILE__).'/../../../..' ));

define( 'DS', DIRECTORY_SEPARATOR );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );

require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );

$mainframe = JFactory::getApplication('site');

jimport( 'joomla.application.module.helper' );

$module = JModuleHelper::getModule('mod_module');

$moduleParams = new JRegistry();

$moduleParams->loadString($module->params);

?>

jquery.google-maps.js

// entire script above

// autoload maps

jQuery(function($) { $('.gmap').googleMaps(); });

第一次尝试

jQuery(document).ready(function($) {

$(".tab").click(function() {

$.getScript(window.location.origin + "jquery.googlemap.js", function() {

$(".div-inner").load("map.php");

});

});

});

第二次尝试

我也试过这种方式,但没有效果:

jQuery(document).ready(function($) {

$(".tab").click(function() {

$.getScript(window.location.origin + "/jquery.googlemap.js", function() {

$.ajax({

type: "GET",

cache: false,

url: '/map.php',

success: function(data) {

$('.div-inner').html(data);

}

});

});

});

});

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值