$(".choose").bind("click", function(event){ var targetId =$(this).attr("data-id"); $(".choose").removeClass("active"); $(".tab-content-page").hide(); switch(targetId){ case "page1": $(this).addClass("active"); showContent($(this).attr("data-url")); $(".page1").show(); break; case "page2": $(this).addClass("active"); $(".page2").show(); break; } }); function showContent(url) { $.ajax({ url: contextPath + url, dataType: "html", success: function(response, status, xhr) { $(".page1").html(response); baiduLocation(); } }); } //表单提交 $("#submit").bind("click",function(){ var name = $("#name").val(); var telephone = $("#telephone").val(); var email = $("#email").val(); var message = $("#message").val(); if(!(name==""&&telephone==""&&email==""&&message=="")){ $.ajax({ type: 'POST', url: contextPath + "/portalMainAction.do?action=saveBBS", data : {name:name,telephone:telephone,email:email,message:message}, dataType: "json", success: function(response, status, xhr) { $("#name").val(""); $("#telephone").val(""); $("#email").val(""); $("#message").val(""); // alert(response.msg); } }); }else{ alert("请留言!"); } }); function baiduLocation(){ $('.address').attr("id","d-map"); // 百度地图API功能 var map = new BMap.Map("d-map"); var point = new BMap.Point(113.380225,23.132001); var marker = new BMap.Marker(point); map.centerAndZoom(point, 18); map.enableScrollWheelZoom(true); //添加地图类型控件 map.addControl(new BMap.NavigationControl()); map.addControl(new BMap.ScaleControl()); map.addControl(new BMap.OverviewMapControl()); map.addControl(new BMap.MapTypeControl({ mapTypes:[ BMAP_NORMAL_MAP, BMAP_HYBRID_MAP ]})); map.setCurrentCity("广州"); map.addOverlay(marker); marker.setAnimation(BMAP_ANIMATION_BOUNCE); } jQuery(function () { showContent($(".tabbar .active").attr("data-url")); });