jquery中在div中load一个html页面内容出错

xhtml页面代码如下
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Jquery菜单








  • 我是菜单2


    • 我是子菜单3

    • 我是子菜单4




<!--点击菜单时,在div中装载页面中的内容-->



需要在content这个div中装载 我是子菜单1中id指向的html页面,这两个页面是在一个路径下的,对应的jquery代码如下
$(".cmenu > li").click(function(){
var html= $(this).children("a").attr('id');
$("#content").load(html);
});
在Chrome浏览器报错
OPTIONS file:///D:/js/IdeaProjects/JqueryTrain/web/aaa.html No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access. jquery.js:2806
XMLHttpRequest cannot load file:///D:/js/IdeaProjects/JqueryTrain/web/aaa.html. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
在Firefox中报错
SyntaxError: An invalid or illegal string was specified
div.innerHTML = wrap[1] + elem + wrap[2];
不知道是跨域的问题还是什么,请大神赐教!

2个回答

本地file浏览不要用chrome,无法使用ajax,要发布网站后通过http来访问

firefox报错应该是你返回的内容有问题。是不是包含了html,head,body这种标签,要去掉

pengpengrose0406
pengpengrose0406 firebug中提示的变量html的值为"aaa.html"
5 年多之前 回复
pengpengrose0406
pengpengrose0406 $(".cmenu > li").click(function(){ var html= $(this).children("a").attr('id'); $("#content").load(html); });
5 年多之前 回复

var html= $(this).children("a").attr('id'); 这段的值是获取URL吗?

az6161311
天空丶蒋 回复pengpengrose0406: 还有一个问题,你的这个html 放在了项目中么?
5 年多之前 回复
az6161311
天空丶蒋 回复pengpengrose0406: 建议不要把地址设为ID吧,你放在其他属性中好一些。
5 年多之前 回复
pengpengrose0406
pengpengrose0406 是的,html页面中的代码是<a href="#" id="aaa.html">我是子菜单1</a>,不知道是不是因为是xhtml的原因
5 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
jQuery load 本地的html 报错跨域问题

本地的一个webAPP, 首页的一个DIV 里 我加载一个本地的HTML页面: $("#oneDive").load("x.html"); 在安卓手机端 提示 No 'Access-Control-Allow-Origin' header is present on the requested resource; 怎么解决这种问题呢?

jquery load 方法回调函数不起作用?

在html页面需要将左侧菜单栏通过jquery load方法引入本页面,随后在对左侧菜单栏进行一些样式更改,代码如下: $(".midd_left_wrap").load(getwebroot()+"vip/vipSaleLeftMenu.html",function(){ $("#evaluation").children().eq(1).children().eq(0).find("a").prepend(">>"); $("#evaluation").children().eq(1).children().eq(0).addClass("currVip"); }); 然而同样的代码,在Firefox中currVip这个样式得到了添加,而在ie和chrome中都没有实现,初学前端,望各位大神多多指教

通过PHP注入HTML和jQuery出错了

<div class="post-text" itemprop="text"> <p>I am beginner and I was trying to dynamically load stuff from database which was successful. Then my next goal was to implement infinite scroll with javascript, but I think the HTML code is being injected into wrong places or something, because when I use <code>data-columns</code> and try to load more with scroll, the styling goes crazy. If I take that out, it loads fine, but the style of my page is all over the place.</p> <p>Screenshot how is should look like <a href="https://i.stack.imgur.com/ZyyO0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZyyO0.jpg" alt=""></a></p> <p>How it looks when I load 4 items at the start and then additional 4 when reaching bottom page <a href="https://i.stack.imgur.com/tiCMa.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tiCMa.jpg" alt=""></a></p> <p>Index.php html in which the data is injected </p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="fh5co-main"&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; &lt;div id="fh5co-board" class="results" data-columns&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> <p>Javascript for infinite load in index.php </p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script type="text/javascript"&gt; var start = 0; var limit = 4; var reachedMax = false; $(window).scroll(function () { if($(window).scrollTop() == $(document).height() - $(window).height()) getData(); }); $(document).ready(function () { getData(); }); function getData() { if(reachedMax) return; $.ajax({ url: 'load_more.php', method: 'POST', dataType: 'text', data: { getData: 1, start: start, limit: limit }, success: function (response) { if (response == "reachedMax") reachedMax = true; else { start += limit; $(".results").append(response); } } }); } &lt;/script&gt;</code></pre> </div> </div> <p>load_more.php</p> <p></p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php include_once "includes/functions.php"?&gt; &lt;?php if(isset($_POST['getData'])) { $start = $_POST['start']; $limit = $_POST['limit']; $query = "SELECT title, image, text FROM posts LIMIT $start, $limit"; $result = mysqli_query(DatabaseConnect(), $query); if (mysqli_num_rows($result) &gt; 0) { $response = ""; while ($data = mysqli_fetch_array($result)) { $response .= ' &lt;div class="item"&gt; &lt;div class="animate-box"&gt; &lt;a href="images/' . $data['image'] . '" class="image-popup fh5co-board-img" title="' . $data['title'] . '"&gt;&lt;img src="images/' . $data['image'] . '" alt="image"&gt;&lt;/a&gt; &lt;/div&gt; &lt;h3&gt;' . $data['title'] . '&lt;/h3&gt; &lt;div class="fh5co-desc"&gt;' . $data['text'] . '&lt;/div&gt; &lt;/div&gt;'; } exit($response); } else exit('reachedMax'); }</code></pre> </div> </div> </div>

“jQuery+ajax”注释表单出错?

<div class="post-text" itemprop="text"> <pre><code>$('form.comment_form').submit(function(e) { e.preventDefault(); var $form = $(this); $.ajax({ url : 'inc/process-form.php', type: 'POST', cache: true, data:({ comment : $form.find('input[name="comment"]').val(), pid : $form.find('input[name="pid"]').val(), post_author : $form.find('input[name="post_author"]').val(), date_comment : $form.find('input[name="date_comment"]').val() }), success : function(results) { $('.show-results').html(results).slideToggle().delay(2000).slideToggle(); $form[0].reset(); $('#all-post').load('home.php #all-post li'); } }); return false; }); </code></pre> <p>上面的代码是“jQuery+ajax”的注释表单。当我提交评论表单时,它工作得很好,但是当我在一秒钟内再次提交它时,它就会重新加载页面。</p> </div>

javascript jquery加载异常

``` <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="../js/jquery-3.1.1.js"></script> <script type="text/javascript" src="../bootstrap/js/bootstrap.js"></script> <script type="text/javascript" src="../bootstrap/js/bootstrap-datetimepicker.js"></script> <script type="text/javascript" src="../bootstrap/js/locales/bootstrap-datetimepicker.zh-CN.js"></script> <script type="text/javascript" src="../js/jquery.cookie.js"></script> <script type="text/javascript" src="../js/pages/main.js"></script> <link rel="stylesheet" href="../bootstrap/css/bootstrap-datetimepicker.css"> <link rel="stylesheet" href="../style/main.css"> <!-- 支持屏幕 --> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <style> *{ font-family:"微软雅黑"; } .form_datetime{ position:relative; z-index:9999; } </style> <script type="text/javascript"> $(function(){ //分页显示 //上一页 var n=0; list(n); $("#pageup").click(function(){ n=n-10; if(n<0){ n=0; } $("#table_content").empty(); list(n); }); $("#page_1").click(function(){ n=0; $("#table_content").empty(); list(n); }); $("#page_2").click(function(){ n=10; $("#table_content").empty(); list(n); }); $("#page_3").click(function(){ n=20; $("#table_content").empty(); list(n); }); $("#page_4").click(function(){ n=30; $("#table_content").empty(); list(n); }); $("#page_5").click(function(){ n=40; $("#table_content").empty(); list(n); }); $("#pagedown").click(function(){ n=n+10; $("#table_content").empty(); list(n); }); //新增 $("#btn_new_save").click(function(){ var info_type=$("#iframe_new").contents().find("#info_type").val();//信息类别 alert(info_type); var type=$("#iframe_new").contents().find("#type").val();//产品类别 var type=$("#iframe_new").contents().find("#type").val();//类型 var release1=$("#iframe_new").contents().find("#release1").val();//发布时间 var effective_s=$("#iframe_new").contents().find("#effective_s").val();//开始时间 var effective_o=$("#iframe_new").contents().find("#effective_o").val();//结束时间 var compete=$("#iframe_new").contents().find("#compete").val();//竞争对手 var region=$("#iframe_new").contents().find("#region").val();//地区 var product=$("#iframe_new").contents().find("#product").val();//产品 var source=$("#iframe_new").contents().find("#source").val();//信息来源 var content=$("#iframe_new").contents().find("#content").val();//主要内容 var impact=$("#iframe_new").contents().find("#impact").val();//影响 $.ajax({ url:"http://localhost:8080/analysis/info/insertall.do", type:"post", data:{"info_type":info_type,"type":type,"release1":release1,"effective_s":effective_s,"effective_o":effective_o, "compete":compete,"region":region,"product":product,"source":source,"content":content,"impact":impact }, resultType:"json", success:function(result){ window.location.href="main.html"; } }); }); //删除 $("#btn_delete").click(function(){ $("input:checkbox[name='checkbox']:checked").each(function(){ id=$(this).val(); $.ajax({ url:"http://localhost:8080/analysis/info/deleteonebyid.do", type:"post", data:{"id":id}, resultType:"json", success:function(){ window.location.href="main.html"; } }); }); }); //修改 $("#modify_btn").click(function(){ var a=0; $("input:checkbox[name='checkbox']:checked").each(function(){ a=a+1; id=$(this).val(); if(a==1){ $.cookie("id",id); }else{ alert("请取消多选"); window.location.href="main.html"; } }); var modify2="<iframe class='embed-responsive-item' src='main/modify.html' id='iframe_modify' name='iframe_modify'></iframe>"; var $modify2=$(modify2); $("#modify_1").append($modify2); $("#btn_modify_save").click(function(){ var info_type=$("#iframe_modify").contents().find("#info_type").val();//信息类别 var type=$("#iframe_modify").contents().find("#type").val();//产品类别 var release1=$("#iframe_modify").contents().find("#release1").val();//发布时间 var effective_s=$("#iframe_modify").contents().find("#effective_s").val();//开始时间 var effective_o=$("#iframe_modify").contents().find("#effective_o").val();//结束时间 var compete=$("#iframe_modify").contents().find("#compete").val();//竞争对手 var region=$("#iframe_modify").contents().find("#region").val();//地区 var product=$("#iframe_modify").contents().find("#product").val();//产品 var source=$("#iframe_modify").contents().find("#source").val();//信息来源 var content=$("#iframe_modify").contents().find("#content").val();//主要内容 var impact=$("#iframe_modify").contents().find("#impact").val();//影响 $.ajax({ url:"http://localhost:8080/analysis/info/updatebyid.do", type:"post", data:{"id":id,"info_type":info_type,"type":type,"release1":release1,"effective_s":effective_s,"effective_o":effective_o, "compete":compete,"region":region,"product":product,"source":source,"content":content,"impact":impact }, resultType:"json", success:function(result){ window.location.href="main.html"; } }); }); }); //查询 $("#search-btn").click(function(){ var selectdata=$("#selectdata").val();//查询下拉选数据 var cont=$("#textdata").val(); $.cookie("selectdata",selectdata); $.cookie("cont",cont); $(".right").empty(); var ifra="<div class='embed-responsive embed-responsive-16by9'>"; ifra+="<iframe class='embed-responsive-item' src='main/search.html'></iframe>"; ifra+="</div>"; var $ifra=$(ifra); $(".right").append($ifra); }); }); </script> <link rel="stylesheet" href="../bootstrap/css/bootstrap.css"> </head> <body> <!-- top --> <div class="row"> <div class="col-md-12" style="height:50px;"> <img src="../image/logo.gif" class="img-responsive" alt="Responsive image" id="logo"> </div> </div> <div class="row"> <!-- left --> <div class="left"> <img src="../image/User.png" class="img-responsive center-block" alt="Responsive image"> <div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="glyphicon glyphicon-th-large"></span> 情报信息 <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu2"> <li><a href="#">Action</a></li> <li><a href="#">Another action</a></li> <li><a href="#">Something else here</a></li> <li role="separator" class="divider"></li> <li><a href="#">Separated link</a></li> </ul> </div> </div> <!-- right --> <div class="right" id="right2"> <div id="info"> <ol class="breadcrumb"> <span class="glyphicon glyphicon-home"></span> <li><a href="#">情报信息</a></li> <li><a href="#" class="active">信息汇总</a></li> </ol> </div> <div id="function_a"> <!-- new delete modify --> <div class="btn-group" role="group" aria-label="..."> <button type="button" class="btn btn-default" data-toggle="modal" data-target="#new" id="new_btn"> <span class="glyphicon glyphicon-pencil"></span> 新建 </button> <button type="button" class="btn btn-default" data-toggle="modal" data-target="#modify" id="modify_btn"> <span class="glyphicon glyphicon-file"></span> 修改 </button> <button type="button" class="btn btn-default" id="btn_delete"> <span class="glyphicon glyphicon-trash"></span> 删除 </button> </div> <!-- 搜索 --> <form class="form-inline pull-right"> <div class="form-group"> <select class="form-control" id="selectdata"> <option value="1">模糊查询</option> <option value="2">2</option> <option value="3">3</option> </select> </div> <div class="form-group"> <input type="text" class="form-control" placeholder="请输入内容" id="textdata"> </div> <button type="submit" class="btn btn-default" id="search-btn"> <span class="glyphicon glyphicon-search"></span> </button> </form> <!-- 动态具体内容 --> <div id="table_content"> </div> <!-- 分页 --> <nav aria-label="Page navigation" id="table_content2"> <ul class="pagination "> <li> <a href="#" aria-label="Previous" id="pageup"> <span aria-hidden="true">&laquo;</span> </a> </li> <li><a href="#" id="page_1">1</a></li> <li><a href="#" id="page_2">2</a></li> <li><a href="#" id="page_3">3</a></li> <li><a href="#" id="page_4">4</a></li> <li><a href="#" id="page_5">5</a></li> <li> <a href="#" aria-label="Next" id="pagedown"> <span aria-hidden="true">&raquo;</span> </a> </li> </ul> </nav> <!-- 模态框绑定数据 --> <!-- 新建 --> <div class="modal fade" id="new" tabindex="-1" role="dialog" aria-labelledby="newLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-lable="Close"> <span aria-hidden="true">&times;</span> </button> <h4 class="modal-title" id="newLabel">新建</h4> </div> <div class="modal-body" id="new_body"> <div class="embed-responsive embed-responsive-4by3"> <iframe class="embed-responsive-item" src="main/new.html" id="iframe_new" name="iframe_new"></iframe> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-primary" id="btn_new_save">保存</button> </div> </div> </div> </div> <!-- 修改 --> <div class="modal fade" id="modify" tabindex="-1" role="dialog" aria-labelledby="modifyLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true"> &times;</span></button> <h4 class="modal-title" id="modifyLabel">修改</h4> </div> <div class="modal-body"> <div class="embed-responsive embed-responsive-4by3" id="modify_1"> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">取消</button> <button type="button" class="btn btn-primary" id="btn_modify_save">保存</button> </div> </div> </div> </div> </div> </div> </div> </body> </html> ``` 当我点击第二部分的search-btn2按钮后,浏览器又重新加载了第一部分,求大神帮忙解决,把js放在页面最后也是同样的效果。

为什么我使用自定义主题打开WordPress页面时会出现此JQuery错误?

<div class="post-text" itemprop="text"> <p>I am pretty new as <strong>WordPress</strong> developer and I have the following problem.</p> <p>I have create the template of this website starting from 0 by myself: <a href="http://www.asper-eritrea.com" rel="nofollow">http://www.asper-eritrea.com</a></p> <p>Now I have add this photo gallery plugin: <a href="https://wordpress.org/plugins/robo-gallery/" rel="nofollow">https://wordpress.org/plugins/robo-gallery/</a></p> <p>The problem is that now, when I access to a page that use this plugin, for example: <a href="http://www.asper-eritrea.com/photo-gallery/" rel="nofollow">http://www.asper-eritrea.com/photo-gallery/</a></p> <p>the gallery is not shown and, into the <strong>FireBug console</strong>, I obtain this error message:</p> <pre><code>TypeError: $ is not a function $(document).ready(function() { </code></pre> <p>So I think that maybe it could depende by the fact that it can't retrieve <strong>JQuery</strong>, but I am absolutly not sure about it because I have the same error also opening the others page of my website so I am not sure that the missing of JQuery into the photogallery page is the cause of my problem.</p> <p>Into the <strong>function.php</strong> file of my template I have the following function that enqueue all the JavaScript resources (including JQuery), in this way:</p> <pre><code>/* Hooks a function on to a specific action (an action is a PHP function that is executed at specific * points throughout the WordPress Core) * @param 'wp_enqueue_scripts': The name of the action to which 'wpb_adding_styles' is hooked (wp_enqueue_scripts * is the proper hook to use when enqueuing items that are meant to appear on the front end) */ add_action('wp_enqueue_scripts', 'wpb_adding_styles'); /* Function automatically executed by the hook 'load_java_scripts': * 1) Load all my JavaScripts */ function load_java_scripts() { // Load JQuery: wp_enqueue_script('jquery'); // Load FlexSlider JavaScript wp_enqueue_script('flexSlider-js', get_template_directory_uri() . '/assets/plugins/flexslider/jquery.flexslider.js', array('jquery'), 'v2.1', true); // Load bootstrap.min.js: wp_enqueue_script('bootstrap.min-js', get_template_directory_uri() . '/assets/bootstrap/js/bootstrap.min.js', array('jquery'), 'v3.0.3', true); // Load FancyBox: wp_enqueue_script('fancy-js', get_template_directory_uri() . '/assets/plugins/fancybox/jquery.fancybox.pack.js', array('jquery'), 'v2.1.5', true); // Load scripts.js: wp_enqueue_script('myScripts-js', get_template_directory_uri() . '/assets/js/scripts.js', array('jquery'), '1.0', true); // Load Modernizer: wp_enqueue_script('myodernizer-js', get_template_directory_uri() . '/assets/js/modernizr.custom.js', array('jquery'), '2.6.2', true); } add_action('wp_enqueue_scripts', 'load_java_scripts'); </code></pre> <p>So what is wrong? What am I missing?</p> <p>The strange thing is that to enqueue JQuery there is:</p> <pre><code>wp_enqueue_script('jquery'); </code></pre> <p>but there is not specified the exact folder of the Jquery source file (as done for the other resources).</p> <p>I have JQuery putted into the <strong>/assets/bootstrap/js/jquery.js</strong> file.</p> </div>

503尝试在WordPress中排队自定义jQuery脚本时出错

<div class="post-text" itemprop="text"> <p>I am trying to set up my very first custom WordPress theme. I am using "front-page.php" to set up a standard landing page, and am trying to use a few jQuery files (all of which are written in compatibility mode). When the functions.php file is written to where I expect it to work, it gives me a 503 error, and the site only works with code I know isn't correct.</p> <p>I have tried enqueuing vs registering, adding admin code, de-activating and re-registering jquery, and adding all the "add_action"s into one line. What am I missing? No JS of any sort has yet worked on this theme. Here is the functions.php file:</p> <pre><code>&lt;?php add_theme_support( 'custom-logo' ); add_theme_support( 'custom-background' ); add_theme_support( 'title-tag' ); function modify_jquery() { wp_dequeue_script('jquery'); wp_deregister_script('jquery'); wp_register_script('jquery-custom', '//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3', 'true'); wp_enqueue_script('jquery-custom'); } add_action( 'wp_enqueue_scripts', 'modify_jquery' ); function theme_scripts() { wp_enqueue_script( 'navbar', get_template_directory_uri() . '/scripts/navbar.js' ); wp_enqueue_script( 'fixedheader', get_template_directory_uri() . '/scripts/fixedheader.js', array( 'jquery' ), null, true ); wp_enqueue_script( 'skills', get_template_directory_uri() . '/scripts/skills.js', array( 'jquery' ), null, true ); } add_action( 'wp_enqueue_scripts', 'theme_scripts' ); function theme_admin_scripts() { wp_enqueue_script( 'navbar', plugin_dir_url( __FILE__ ) . '/scripts/navbar.js' ); wp_enqueue_script( 'fixedheader', plugin_dir_url( __FILE__ ) . '/scripts/fixedheader.js', array( 'jquery' ), null, true ); wp_enqueue_script( 'skills', plugin_dir_url( __FILE__ ) . '/scripts/skills.js', array( 'jquery' ), null, true ); } add_action( 'admin_enqueue_scripts', 'theme_admin_scripts' ); function register_navigation() { $args = array( 'description' =&gt; '', 'class' =&gt; '', 'before_widget' =&gt; '', 'after_widget' =&gt; '', 'before_title' =&gt; '&lt;h3 class="widget-title"&gt;', 'after_title' =&gt; '&lt;/h3&gt;' ); register_navigation($args); } add_action( 'widgets_init', 'register_navigation' ); ?&gt; </code></pre> <p>I would like for my site to have a navigation menu that comes down as the reader scrolls down (this worked in a static page before I made it a wordpress theme file), among some other jQuery functionality. The rest of the site works fine, pictures load, etc. but I have not been able to add any script successfully. Any help is greatly appreciated!</p> </div>

(Jquery)404尝试使用ajax查找php文件时出错

<div class="post-text" itemprop="text"> <p>I've been trying to fix this for the past 2 hours, but I haven't been able to fix it. So I have the current filesetup:</p> <pre><code>classes -html --index.html --front_gallery.php -javascript --gallary.js </code></pre> <p>And I've been following the tutorial here: <a href="http://webdevelopingcat.com/jquery-php-beginner-tutorial-ajax/" rel="nofollow">http://webdevelopingcat.com/jquery-php-beginner-tutorial-ajax/</a>, and I've followed it almost exactly. I'm currently just running the site off the computer.</p> <p>So, if I run it off the Adobe Brackets live preview, I get the 404 error, saying that the file is not found. However, if I run it directly, I get this error:</p> <pre><code> XMLHttpRequest cannot load file:///C:/Users/myaka_000/Dropbox/Public/dylan_ferris_website/classes/html/front_gallery.php. Cross origin requests are only supported for protocol schemes: http, data, chrome-extension, https, chrome-extension-resource. </code></pre> <p>Here is the gallery.js code:</p> <pre><code>$(document).ready(function() { $(function() { $("#contact").submit(function(e) { e.preventDefault(); var formData = $(this).serialize(); window.console.log( formData ) $.ajax({ type: "POST", url: "front_gallery.php", data: formData, success: function(resp){ window.console.log(resp); } }); }); }); }); </code></pre> <p>front_gallery.php:</p> <pre><code>&lt;? print_r( $_POST ); </code></pre> </div>

页面内容显示不出来 ,看不懂哪里出错了。

``` main.jsp: <%@ page contentType="text/html;charset=UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>title</title> <%@ include file="../../include/common.jsp"%> <script type="text/javascript"> //定义了一个命名空间,ExpertsMntn.main.xxxx可以直接调用 $.namespace("ExpertsMntn.main"); ExpertsMntn.main.add=function() { $("#ExpertsMntnDetailWin").dialog({ href:'add', title:'添加', draggable:false, //设置dialog自由尺寸 onResize:function(){ $('#ExpertsMntnGrid').datagrid('resize'); } }).dialog('open'); }; ExpertsMntn.main.edit=function() { var row = $('#ExpertsMntnGrid').datagrid('getSelections'); //getSelections:可以多行选中操作; getSelected:只能单行操作; if(row.length==1){ $("#ExpertsMntnDetailWin").dialog({ href:'edit/'+row[0].id, title:'编辑', draggable:false, onResize:function(){ $('#ExpertsMntnGrid').datagrid('resize'); } }).dialog('open'); }else{ $.message.alert("Please select a record only!"); } }; ExpertsMntn.main.del=function() { //获取datagrid选中的数据行 var row = $("#ExpertMntnGrid").datagrid('getSelections'); if(row.length>=1){ //调用easyui的确认框 $.message.comfirm('确认','确认删除?',function(r) { if(r){ var ids = [ ]; //将选中的数据库的id压入ids[]数组; for (var i = 0; i < row.length; i++) { ids.push(row[i].id); } //调用jquery的post方法请求delete地址 $.post('del',{ ids:ids.join(',') },function(result){ //动态页200状态post成功回调并且服务器返回标准json数据执行回调函数 if(result){ // reload data $('#ExpertsMntnGrid').datagrid('clearSelections'); $('#ExpertsMntnGrid').datagrid('reload'); } },"json"); //指定将服务器返回的内容处理成json类型(此外,还可以返回 html、text之类) } }); }else{ $.message.alert('Please select a record only!'); } }; ExpertsMntn.main.listSearch=function() { $('#ExpertsMntnGrid').datagrid('load', { }); }; ExpertsMntn.main.init = function() { $('#ExpertsMntnGrid').datagrid({ //建表?建表插件用法 url:'search', method:'get', pageSize:20, toolbar:'#', fit : true, pagination : true, idField : "id", //支持分页选择记录 pagePosition : "bottom", rownumbers : true, border : false, singleSelect : false, striped : true, fitColumns : true, selectOnCheck : true, checkOnSelect : true, columns:[[{ field:'check', title : '', checkbox : true },{ field : 'id', title : '', width : 22, align : 'center', halign : 'center', sortable : true },{ field:'name', title:'姓名', width:22, align : 'center', halign : 'center', sortable : false },{ field:'sex', title:'性别', width:22, align : 'center', halign : 'center', sortable : false },{ field:'birthday', title:'出生日期', width:22, align : 'center', halign : 'center', sortable : false },{ field:'partymember', title:'政治状态', width:22, align : 'center', halign : 'center', sortable : false },{ field:'itemid', title:'专业', width:22, align : 'center', halign : 'center', sortable : false },{ field:'orgid', title:'所属组织', width:22, align : 'center', halign : 'center', sortable : false },{ field:'telephone', title:'联系方式', width:22, align : 'center', halign : 'center', sortable : false },{ field:'experience', title:'经历', width:22, align : 'center', halign : 'center', sortable : false },{ field:'remarks', title:'备注', width:22, align : 'center', halign : 'center', sortable : false },{ field:'content', title:'照片附件', width:22, align : 'center', halign : 'center', sortable : false },{ field:'photo-suffix', title:'照片文件后缀名', width:22, align : 'center', halign : 'center', sortable : false }]], //查看操作,onDblClickRow onDblClickRow : function(index, row) { $('#ExpertsMntnGrid').datagrid("clearSelections"); $('#ExpertsMntnGrid').datagrid("selectRow", index); $('#ExpertsMntnDetailWin').dialog({ href : 'view/' + row.id, title : "查看", draggable : false, onResize : function() { $('#ExpertsMntnGrid').datagrid('resize'); } }).dialog('open'); } }); }; $(document).ready(function() { ExpertsMntn.main.init(); }); </script> </head> <body> <div class="easyui-layout" fit="true" border="false" > <div region="north" border="false" > <div id="toolbar" border="false" class="dialog-toolbar" style="border-bottom-style: solid; border-bottom-width: 1px; border-bottom-color: #DDDDDD"> <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'" onclick="ExpertsMntn.main.add()">添加</a> <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'" onclick="ExpertsMntn.main.edit()">编辑</a> <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'" onclick="ExpertsMntn.main.del()">删除</a> </div> </div> <div region="center" border="false" style="width: 100%; height: 100%"> <table id="ExpertsMntnGrid"></table> </div> <div id="ExpertsMntnDetailWin" class="easyui-dialog" title="" style="width: 450px; height: 750px;" data-options="modal:true,closed:true"></div> </div> </body> </html> detail.jsp: <%@ page contentType="text/html;charset=UTF-8"%> <%@ include file="../../include/header.jsp"%> <script type="text/javascript"> $.namespace("ExpertsMntn.detail"); ExpertsMntn.id="${(ExpertsMntnEntity.id)==null?0:(ExpertsMntnEntity.id)}"; ExpertsMntn.detail.mode = "${mode}"; ExpertsMntn.detail.save = function(){ var url = $.ctx+'/zjkwh/save/'+ ExpertsMntn.id; $('#ExpertsMntnForm').form('submit', { url: url, onSubmit: function(param) { if(ExpertsMntn.detail.mode=='edit'){ return $(this).form('validate'); } var flag = false; $.ajax({ type : "post", url : 'check', dataType : "json", data : { id : $('#id').val() }, async : false, success : function(result) { if (result == true) { flag = true; } } }); if(!flag){ return $(this).form('validate'); } else { $.messager.alert('数据已存在'); $('#ExpertsMntnGrid').datagrid('load'); return !flag; } }, success: function(result) { var data = (new Function("","return "+ result))(); $('#ExpertsMntnGrid').datagrid('reload'); if (data.id) { ExpertsMntn.id = data.id; $.messager.alert('提示', '保存成功!','',function(){ $('#ExpertsMntnDetailWin').dialog('close'); }); } else { $.messager.show({ title: 'Error', msg: result }); } } }); } $(document).ready(function() { }); </script> <div class="easyui-layout" region="center" style="height:700px;border:1px dashed #FFFFFF"> <c:if test="${(mode=='edit') || (mode=='add')}"> <div class="editform" style="border:1px dashed #FFFFFF"> <form id="ExpertsMntnForm" method="post" novalidate style="margin-bottom: 0"> <input id="id" name="id" type="hidden" value="${ExpertsMntnEntity.id }" /> <ul style="list-style-type: none; height: 5px"></ul> "validType:'length[1,50]'" value="${ExpertsMntnEntity.wonawardz}" size="20" style="width: 140px;height:30px;line-height:30px;border-style:none;margin-right:3px;float: left;background: url('${ctx}/static/images/inputbg.png') ;background-size: 100% 100%; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${ctx}/static/images/inputbg.png', sizingMethod='scale')\9;" /> </li> </ul>--> </div> </c:if> <c:if test="${mode=='view'}"> <div class="editform"> <table border=1> <tbody> <tr> <td class="label"><label>&nbps;ID:</label></td> <td>${expertsMntnEntity.id}</td> </tr> <tr> <td class="label"><label>姓名:</label></td> <td>${expertsMntnEntity.name}</td> </tr> <tr> <td class="label"><label>性别:</label></td> <td>${expertsMntnEntity.sex}</td> </tr> <tr> <td class="label"><label>出生日期:</label></td> <td>${expertsMntnEntity.birthday}</td> </tr> <tr> <td class="label"><label>专业:</label></td> <td>${expertsMntnEntity.itemid}</td> </tr> <tr> <td class="label"><label>获得奖项:</label></td> <td>${expertsMntnEntity.wonawardz}</td> </tr> <tr> <td class="label"><label>经历:</label></td> <td>${expertsMntnEntity.experience}</td> </tr> <tr> <td class="label"><label>备注:</label></td> <td>${expertsMntnEntity.remarks }</td> </tr> </tbody> </table> </div> </c:if> </div> 只有添加才能显示出内容,编辑和查看操作在对话框中显示不出来,就连div框都显示不了!对话框能打开,但是里面什么东西都没有! ```

在codeigniter中在控制器中加载模型时出错:消息:未定义属性:Cart :: $ load

<div class="post-text" itemprop="text"> <p>I am a beginner in codeigniter and currently I am working on a shopping cart, taking help from <a href="http://net.tutsplus.com/tutorials/php/how-to-build-a-shopping-cart-using-codeigniter-and-jquery/" rel="nofollow noreferrer">http://net.tutsplus.com/tutorials/php/how-to-build-a-shopping-cart-using-codeigniter-and-jquery/</a> tutorial. I am using codeigniter 2.1.3. </p> <p>I am getting an error:</p> <blockquote> <p>A PHP Error was encountered</p> <p>Severity: Notice</p> <p>Message: Undefined property: Cart::$load</p> <p>Filename: controllers/cart.php<br> Line Number: 7</p> <p>Fatal error: Call to a member function model() on a non-object in D:\xampp\htdocs\ci\application\controllers\cart.php on line 7</p> </blockquote> <p>Can someone please tell me why it is not working?</p> <p>The name of my controller is cart.php</p> <pre><code>&lt;?php class Cart extends CI_Controller { public function Cart() { //parent::CI_Controller(); // We define the the Controller class is the parent. $this-&gt;load-&gt;model("cart_model"); // Load our cart model for our entire class } public function index() { $data['products'] = $this-&gt;cart_model-&gt;retrieve_products(); // Retrieve an array with all products print_r($data['products']); //$data['content'] = 'cart/products'; // Select view to display //$this-&gt;load-&gt;view('index', $data); // Display the page } } ?&gt; </code></pre> <p>and my model is cart_model.php</p> <pre><code>&lt;?php class Cart_model extends CI_Model{ //public function _construct(){ //parent::_construct(); //} public function retive_products(){ $query = $this-&gt;db-&gt;get("products"); return $query-&gt;result_array(); } } /* End of file cart_model.php */ /* Location: ./application/models/cart_model.php */ ?&gt; </code></pre> </div>

ajax,jquery联系表单与reCAPTCHA v2 - 500内部服务器错误

<div class="post-text" itemprop="text"> <p>I have a jquery/ajax contact form and tried to add the Google reCAPTCHA v2, but it isn't working. The form worked before I included the reCAPTCHA. The reCAPTCHA shows up (although it takes forever to load), and I can verify that I'm not a robot (which takes forever as well), but when I click on my submit button, the spot where I display my status messages shows this, including the code, as text:</p> <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt; &lt;html&gt;&lt;head&gt; &lt;title&gt;500 Internal Server Error&lt;/title&gt; &lt;/head&gt;&lt;body&gt; &lt;h1&gt;Internal Server Error&lt;/h1&gt; &lt;p&gt;The server encountered an internal error or misconfiguration and was unable to complete your request.&lt;/p&gt; &lt;p&gt;Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.&lt;/p&gt; &lt;p&gt;More information about this error may be available in the server error log.&lt;/p&gt; &lt;/body&gt;&lt;/html&gt; </code></pre> <p>I can't figure out what's going wrong. I followed Google's instructions and included this just before my tag:</p> <pre><code>&lt;script src='https://www.google.com/recaptcha/api.js'&gt;&lt;/script&gt; </code></pre> <p>and integrated my form like this:</p> <pre><code>&lt;div class="g-recaptcha" data-sitekey="6LeehAsUAAAAAILDfzizJ23GHH7yPGxWBFP_3tE7"&gt;&lt;/div&gt; </code></pre> <p>I tried many different ways to integrate it in my mailer.php file without success, and I couldn't find many tutorials that address v2 specifically (not sure if it even matters). My most recent version of the mailer.php is based on an <a href="https://github.com/google/recaptcha/blob/master/examples/example-captcha.php" rel="nofollow noreferrer">example</a> I found on <a href="https://github.com/google/recaptcha" rel="nofollow noreferrer">Google's recaptcha Github</a>:</p> <pre><code>&lt;?php require_once __DIR__ . 'inc/autoload.php'; // If the form was submitted if ($_SERVER["REQUEST_METHOD"] == "POST") { // If the Google Recaptcha box was clicked if(isset($_POST['g-recaptcha-response']) &amp;&amp; !empty($_POST['g-recaptcha-response'])){ $siteKey = '6LeehAsUAAAAAILDfzizJ23GHH7yPGxWBFP_3tE7'; $secret = 'I-removed-this-for-now'; $recaptcha = new \ReCaptcha\ReCaptcha($secret); $resp = $recaptcha-&gt;verify($gRecaptchaResponse, $remoteIp); // If the Google Recaptcha check was successful if ($resp-&gt;isSuccess()){ $name = strip_tags(trim($_POST["name"])); $name = str_replace(array(" "," "),array(" "," "),$name); $email = filter_var(trim($_POST["email"]), FILTER_SANITIZE_EMAIL); $message = trim($_POST["message"]); if ( empty($name) OR empty($message) OR !filter_var($email, FILTER_VALIDATE_EMAIL)) { http_response_code(400); echo "Oops! There was a problem with your submission. Please complete the form and try again."; exit; } $recipient = "I-removed-this@for-now.com"; $subject = "New message from $name"; $email_content = "Name: $name "; $email_content .= "Email: $email "; $email_content .= "Message: $message "; $email_headers = "From: $name &lt;$email&gt;"; if (mail($recipient, $subject, $email_content, $email_headers)) { http_response_code(200); echo "Thank You! Your message has been sent."; } else { http_response_code(500); echo "Oops! Something went wrong, and we couldn't send your message. Check your email address."; } } // If the Google Recaptcha check was not successful else { echo "Robot verification failed. Please try again."; } } // If the Google Recaptcha box was not clicked else { echo "Please click the reCAPTCHA box."; } } // If the form was not submitted // Not a POST request, set a 403 (forbidden) response code. else { http_response_code(403); echo "There was a problem with your submission, please try again."; } ?&gt; </code></pre> <p>This is the app.js that goes with my contact form (I haven't changed this at all when trying to include the reCAPTCHA):</p> <pre><code>$(function() { // Get the form. var form = $('#ajax-contact'); // Get the messages div. var formMessages = $('#form-messages'); // Set up an event listener for the contact form. $(form).submit(function(e) { // Stop the browser from submitting the form. e.preventDefault(); // Serialize the form data. var formData = $(form).serialize(); // Submit the form using AJAX. $.ajax({ type: 'POST', url: $(form).attr('action'), data: formData }) .done(function(response) { // Make sure that the formMessages div has the 'success' class. $(formMessages).removeClass('error'); $(formMessages).addClass('success'); // Set the message text. $(formMessages).text(response); // Clear the form. $('#name').val(''); $('#email').val(''); $('#message').val(''); }) .fail(function(data) { // Make sure that the formMessages div has the 'error' class. $(formMessages).removeClass('success'); $(formMessages).addClass('error'); // Set the message text. if (data.responseText !== '') { $(formMessages).text(data.responseText); } else { $(formMessages).text('Oops! An error occured, and your message could not be sent.'); } }); }); }); </code></pre> <p>The autoload.php comes directly from the Google Github, and I didn't make any changes:</p> <pre><code>&lt;?php /* An autoloader for ReCaptcha\Foo classes. This should be required() * by the user before attempting to instantiate any of the ReCaptcha * classes. */ spl_autoload_register(function ($class) { if (substr($class, 0, 10) !== 'ReCaptcha\\') { /* If the class does not lie under the "ReCaptcha" namespace, * then we can exit immediately. */ return; } /* All of the classes have names like "ReCaptcha\Foo", so we need * to replace the backslashes with frontslashes if we want the * name to map directly to a location in the filesystem. */ $class = str_replace('\\', '/', $class); /* First, check under the current directory. It is important that * we look here first, so that we don't waste time searching for * test classes in the common case. */ $path = dirname(__FILE__).'/'.$class.'.php'; if (is_readable($path)) { require_once $path; } /* If we didn't find what we're looking for already, maybe it's * a test class? */ $path = dirname(__FILE__).'/../tests/'.$class.'.php'; if (is_readable($path)) { require_once $path; } }); </code></pre> <p>I would really appreciate your help!</p> </div>

jQuery扩展可能冲突了 你这个坏人还我的方法 /(ㄒoㄒ)/~~!

**【发现CSDN大坑比,竟然评论出错~ 俺的QQ:980581089 邮箱也是这个 你懂得~ 唉 心累】** 项目中有需要图片浏览的一个需求,然后在网上找到一个很棒的工具 叫做viewer.js [GitHub地址](https://github.com/fengyuanchen/viewer "") 很容易就集成到项目中了,但是突然发现网页中左侧的菜单不能折叠了。。。 到项目中看了下,发现菜单控制用的是两个js文件,一个叫做sb-admin-2.js 代码如下: ``` $(function() { $('#side-menu').metisMenu(); }); //Loads the correct sidebar on window load, //collapses the sidebar on window resize. // Sets the min-height of #page-wrapper to window size $(function() { $(window).bind("load resize", function() { topOffset = 50; width = (this.window.innerWidth > 0) ? this.window.innerWidth : this.screen.width; if (width < 768) { $('div.navbar-collapse').addClass('collapse'); topOffset = 100; // 2-row-menu } else { $('div.navbar-collapse').removeClass('collapse'); } height = ((this.window.innerHeight > 0) ? this.window.innerHeight : this.screen.height) - 1; height = height - topOffset; if (height < 1) height = 1; if (height > topOffset) { $("#page-wrapper").css("min-height", (height) + "px"); } }); var url = window.location; var element = $('ul.nav a').filter(function() { return this.href == url || url.href.indexOf(this.href) == 0; }).addClass('active').parent().parent().addClass('in').parent(); if (element.is('li')) { element.addClass('active'); } }); ``` 一个叫做metisMenu.js[GitHub地址](https://github.com/onokumus/metisMenu "") 然后谷歌浏览器调试js 提示_ sb-admin-2.js:3 Uncaught TypeError: $(...).metisMenu is not a function_ 说metisMenu不是个方法,然而在metisMenu中有这么一个方法: ``` var pluginName = "metisMenu"; $.fn[pluginName] = function(options) { this.each(function () { var el = $(this); if (el.data(pluginName)) { el.data(pluginName).remove(); } el.data(pluginName, new Plugin(this, options)); }); return this; }; ``` 不懂什么意思,就查了下语法 说是添加一个jQuery 对象的扩展方法。显然之前是没问题的,加了viewer.js这个文件后这个扩展给搞没了或者是什么的。 是不是viewer.js中有某些东西把外部js文件中对jQuery的扩展给取消了? 对js不太熟悉,跪求路过的各位仙家指点迷津,不胜感激!

有什么办法可以让页面变化时加载脚本文件

各位大佬,现在遇到这样的一个问题,有一个脚本文件,页面加载完毕后脚本就可以起作用,但是用ajax写预加载(重写html)的时候,脚本文件就不起作用了,请问有什么办法可以让页面变化时加载脚本文件吗??? ![图片说明](https://img-ask.csdn.net/upload/201812/18/1545091465_32276.png) var counter = 1; // 每页展示4个 var num = 6; var pageStart = 0, pageEnd = 0; // dropload $('.Quotation').dropload({ scrollArea: window, domUp: { domClass: 'dropload-up', domRefresh: '<div class="dropload-refresh">↓下拉刷新</div>', domUpdate: '<div class="dropload-update">↑释放更新</div>', domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>' }, domDown: { domClass: 'dropload-down', domRefresh: '<div class="dropload-refresh">↑上拉加载更多</div>', domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>', domNoData: '<div class="dropload-noData">已经到达底部</div>' }, loadUpFn: function (me) { me.lock(); // 无数据 me.noData(); me.resetload(); }, loadDownFn: function (me) { var result = ''; counter++; pageEnd =<%=pageCount %> +1;//总页数 pageStart = counter; if (pageStart <= pageEnd) { //alert(pageStart); // alert(pageEnd); $.ajax({ type: 'GET', url: '/Quotation/ArticleWeList1.ashx', dataType: 'json', data: { action: "ArticleWeList", cid: "<%=CId %>", searchName: "<%=SearchName %>", menuid: "<%=MID %>", page: counter }, success: function (data) { // alert(i) for (var i = 0; i < data.length; i++) { result += '<div class="wow fadeInUp" data-wow-delay="0.3s">' + '<span id="ctl00_ContentPlaceHolder_Body_rptNewsList_ctl00_lbWeListMain" class="WeListMain">' + '<span class="WeList_p btns" data-clipboard-action="copy" data-clipboard-target="#foo_'+ data[i].ArticleId + '" ' + data[i].Color + '>' + data[i].Title + '' + ' <input id="foo_'+data[i].ArticleId+'" class="copy-id" type="text" value="' + data[i].Title + '">' + '</span>' + '<ul data-am-widget="gallery" class="We_Title_Kuang am-gallery am-avg-sm-2 am-avg-md-3 am-avg-lg-4 am-gallery-overlay" data-am-gallery="{ pureview: true }">' + '<div class="">' + '' + data[i].ArticleImg + '' + '</div>' + '</ul>' + '<span id="" class="DateTime">' + data[i].UpdateTime + '' + '</span>' + '</span>' + '</div>'; if ((i + 1) > data.length) { //alert(i + 1) // 锁定 me.lock(); // 无数据 me.noData(); break; } } // 为了测试,延迟1秒加载 setTimeout(function () { $('.P_Exhibition').append(result); // 每次数据加载完,必须重置 me.resetload(); }, 1000); }, error: function (xhr, type) { alert('Ajax error!'); // 即使加载出错,也得重置 me.resetload(); } }); } else { //alert(pageStart); // 锁定 me.lock(); // 无数据 me.noData(); me.resetload(); } }, threshold: 50 }); }); </script> <script src="/Upload/WeCha/js/amazeui.js"></script> ``` ```

通过Ajax请求调用页面时出现JavaScript错误

<div class="post-text" itemprop="text"> <p>My page works fine if i navigate to the page <code>http://localhost/abintegro/tests/sjt/1/index.html</code> however when I call the page via Ajax I get this error in inspect element console.</p> <p><strong>Error</strong></p> <blockquote> <p>Uncaught ReferenceError: Test is not defined</p> <pre><code>at HTMLDocument.&lt;anonymous&gt; (&lt;anonymous&gt;:6:21) at j (http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js?_=1476785885327:2:29948) at k (http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js?_=1476785885327:2:30262) </code></pre> </blockquote> <p>within <code>index.html</code> if i comment out the function bellow the error is no more, however I need the function for the page to work.</p> <p><strong>My function</strong></p> <pre><code>( function($, undefined) { $(function() { var test = new Test({ testName: "Situational Judgement Test 1", dataURL : "./getresultshtml.php", sendEmailURL: "./sendresultsbyemail.php", contentFolder : "./", solutionURL: "../../../content/f/id/21/", userID: 0, courseItemID: 42, XMLFile: "exam.xml", isStandalone: false }); test.start(); }); }(jQuery)); </code></pre> <p>the Ajax call in <code>script.js</code> is as follows.</p> <p>(once <code>index.html</code>is called this way I get the error above)</p> <p><strong>The Call</strong></p> <pre><code> $("#test3").click(function (event) { $.post( "tests/sjt/1/index.html", function (data) { $('.stage2').html(data); } ); }); </code></pre> <p><strong>//////////////Update//////////////////////</strong></p> <p><strong>Test if used in a external file</strong></p> <pre><code> function Test(settings){ var defaults = { testName: "", dataURL: "", sendEmailURL: "", contentFolder: "", solutionURL: "", downloadURL: "", timesTaken: 0, userID: 0, courseItemID: 0, XMLFile: "", isStandalone: false }; //merge defaults and settings this.settings = $.extend({}, defaults, settings); //module fields this.testData = null; //set up main test objects this.eventHub = new EventHub(); this.Loader = new Loader(this.eventHub, this.settings); } Test.prototype.start = function(){ var context = this; //load xml data and start test when data returns this.eventHub.subscribeOnce(this, "loader/xml", function(data){ //get returned data object context.testData = data; context.settings.testType = data.testType; //initialise the test runner context.Runner = new Runner(context.eventHub, context.settings, context.testData); context.UI = new UI(context.eventHub, context.settings); context.Data = new Data(context.eventHub, context.settings); //start preload of images and subscribe to loaded event context.Loader.preloadImages(context.testData.questions); //show intro screen context.UI.prepareIntro(context.testData.introText); }); this.Loader.loadXML(this.settings.XMLFile); } </code></pre> </div>

Javascript和传递Cookie问题

<div class="post-text" itemprop="text"> <p>I am working on a script which takes the vertical scroll posistioning of a div container and on document unload it stores the vertical posistion within a cookie and then loads it on load.</p> <p>Originally I had the following:</p> <pre><code>$('#GridViewContainer').load('claims.php', function() { $(this).scrollTop($(this).prop("scrollHeight") - $(this).height()); }); </code></pre> <p>Which is ok if you are refreshing the page but if you are reloading the page with parameters it will lose it's position. Solution? Store it in a cookie...</p> <p>However I am having issues with storing the value and loading it on load. I am using php to return all current Cookies and I can see I am setting the cookie "div_yCookie" but the content seems to be:<br> <strong><em>'div_yCookie' =&gt; string '[object Object]' (length=15)</em></strong></p> <p>(I am a complete Javascript and jQuery novice... No doubt it is something obvious but can someone help?</p> <pre><code>&lt;script&gt; function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i &lt; ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } $(document).ready(function () { $('#GridViewContainer').load('claims.php', function() { var x = readCookie('div_yCookie'); $(this).scrollTop($(this).prop("scrollHeight") - x); //$(this).scrollTop($(this).prop("scrollHeight") - $(this).height()); }); }); window.onbeforeunload = function(){ var div_y = $('#GridViewContainer').scrollTop($('#GridViewContainer').prop("scrollHeight") - $('#GridViewContainer').height()); createCookie('div_yCookie',div_y,0.5); }; &lt;/script&gt; </code></pre> <p><strong>UPDATE</strong> It turns out it actually works when you refresh the page however it still doesn't work when you reload the page.</p> </div>

多个输入文件元素上的addEventListener

<div class="post-text" itemprop="text"> <p>I have a foreach loop that provides me with multiple (about 5) file input elements. </p> <p>I got the form to work with a simple submit button, but I would like to get it working without one too (upload when selected).</p> <p>I get stuck trying to let Js or jQuery react to whichever button is clicked.</p> <p>My <code>php</code> that provides the upload buttons:</p> <pre><code>&lt;?php $getCampaign = new Crud(); $query = "SELECT * FROM `table`"; $aRow = $getCampaign-&gt;getData($query); if ($aRow == false){ echo '&lt;div class="alert alert-danger"&gt;No Campaigns!&lt;br/&gt;&lt;/div&gt;'; } else { foreach ($aRow as $row) { echo '&lt;div class="row marginBottom"&gt;'; echo '&lt;div class="col-sm-2"&gt;&lt;strong&gt; '. $row['campaign'] .' &lt;/strong&gt;&lt;/div&gt;'; echo '&lt;div class="col-sm-5"&gt; '. $row['sort'] .'&lt;/div&gt;'; echo '&lt;div class="col-sm-5"&gt; &lt;form method="post" enctype="multipart/form-data" action="process-upload-excel.php"&gt; &lt;input type="file" id="' . $row['campaign'] . $row['sort'] .'" class="btn btn-primary btn-sm"&gt; &lt;button type="submit" class="addfile"&gt;Upload File!&lt;/button&gt; &lt;/form&gt;'; echo '&lt;/div&gt;&lt;/div&gt;'; } &lt;hr/&gt; &lt;div id="content"&gt; &lt;div id="response"&gt;&lt;/div&gt; &lt;ul id="image-list"&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>Start of <code>js</code> (what I got so far):</p> <pre><code>//Check for FormData if (window.FormData) { formdata = new FormData(); $(".addfile").css("display", "none"); } ???.addEventListener("change", function (evt) { document.getElementById("response").innerHTML = '&lt;i class="fa fa-spinner fa-pulse fa-2x fa-fw"&gt;&lt;/i&gt;&lt;span class="sr-only"&gt;Loading...&lt;/span&gt;'; // rest of code checking name of file etc. } </code></pre> <p>I got 'Campaign' and 'Sort' in a DB.</p> <p>Out of these entries I create the input file elements. So people can upload the right file for the right Campaign.</p> <p>But how do I use the addEvenListener the correct way for this example?</p> <p>I hope someone can educate me.</p> <p>Thanks in advance</p> </div>

求助~~layer在form表单事件里无法正常使用

各位大佬,小白遇到了一个奇葩的问题: 在form表单里添加一个Button按钮点击事件,调用layer弹框,奇怪的是layer立即关闭,关闭之后会刷新一下界面,实在是找不到什么问题呀?求助~~~~~~~~ ------------把主要的代码贴出来------------ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <form > <div class="col-lg-12 col-sm-12 col-xs-12" style="margin-top: 10px;"> <button style="background-color: #1581CB;color: #fff;" id="select" >弹框</button> </div> </form> </body> </html> <script src="./js/jquery-1.10.1.min.js"></script> <script src="./js/layer/layer.js"></script> <script> $("#select").click(function() layer.alert('内容', { icon: 1, skin: 'layer-ext-moon' }) }); </script>

在yii2上使用Pjax时出错

<div class="post-text" itemprop="text"> <p>I am trying to implement content autoload wit the aid of pjax on yii2 but I get Uncaught TypeError: jQuery(...).pjax is not a function. I can't solve it. This is my view file:</p> <pre><code>&lt;?php use yii\widgets\Pjax; use yii\helpers\Html; ?&gt; &lt;title&gt;Web-shop&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="sort-panel"&gt; &lt;div class="container"&gt; &lt;div class="sort"&gt; &lt;p&gt;&lt;span class="hidden-xs"&gt;Sort by:&amp;nbsp;&lt;/span&gt; &lt;?php Pjax::begin([]); ?&gt;&lt;span class="sorter active-sorter"&gt; &lt;?= Html::a( 'name&amp;nbsp;', ['site/inner', 'action' =&gt; 'name'], ['class' =&gt; 'sorter name'] ) ?&gt; &lt;span class="glyphicon glyphicon-chevron-down"&gt;&lt;/span&gt; &lt;/span&gt;&amp;nbsp;|&amp;nbsp;&lt;?php Pjax::end(); ?&gt; &lt;?php Pjax::begin([]); ?&gt;&lt;span class="sorter"&gt;&lt;?= Html::a( 'price&amp;nbsp;', ['site/inner', 'action' =&gt; 'price'], ['class' =&gt; 'sorter name'] ) ?&gt; &lt;span class="glyphicon"&gt;&lt;/span&gt; &lt;/span&gt;&amp;nbsp;|&amp;nbsp;&lt;?php Pjax::end(); ?&gt; &lt;?php Pjax::begin([]); ?&gt;&lt;span class="sorter"&gt;&lt;?= Html::a( 'date&amp;nbsp;', ['site/inner', 'action' =&gt; 'date'], ['class' =&gt; 'sorter name'] ) ?&gt; &lt;span class="glyphicon"&gt;&lt;/span&gt; &lt;/span&gt;&amp;nbsp;|&amp;nbsp;&lt;?php Pjax::end(); ?&gt; &lt;?php Pjax::begin([]); ?&gt;&lt;span class="sorter"&gt;&lt;?= Html::a( 'popularity&amp;nbsp;', ['site/inner', 'action' =&gt; 'popularity'], ['class' =&gt; 'sorter name'] ) ?&gt; &lt;span class="glyphicon"&gt;&lt;/span&gt; &lt;/span&gt;&lt;?php Pjax::end(); ?&gt; &lt;/p&gt; &lt;/div&gt; &lt;div class="view hidden-xs"&gt; &lt;span class="glyphicon glyphicon-th active-view"&gt;&lt;/span&gt;&amp;nbsp; &lt;span class="glyphicon glyphicon-th-list"&gt;&lt;/span&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="container inner-content push"&gt; &lt;?php foreach ($posts as $post) { ?&gt; &lt;div class="event-list"&gt; &lt;a href="#" class="image-wrapper event-list-image col-sm-4" style="background-image: url(events/party-girls.jpg);"&gt;&lt;/a&gt; &lt;div class="event-list-content col-sm-8"&gt; &lt;div class="col-xs-6 event-list-heading"&gt; &lt;h1&gt;&lt;a href="#"&gt;&lt;?=$post-&gt;title?&gt;&lt;/a&gt;&lt;/h1&gt; &lt;p class="event-list-date"&gt;&lt;?=$post-&gt;date?&gt;&lt;/p&gt; &lt;/div&gt; &lt;p class="col-xs-6 event-list-price"&gt;&lt;?=$post-&gt;price?&gt;&lt;/p&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;div class="event-list-desc"&gt; &lt;?=$post-&gt;full_text?&gt; &lt;a href="&lt;?=$post-&gt;link?&gt;" class="go_to"&gt;Go to&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;?php } ?&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;?php Pjax::begin(['enableReplaceState' =&gt; false]); $a = $a +1;?&gt; &lt;?= Html::a( 'Load More', ['site/inner', 'action' =&gt; $action,'a' =&gt; $a], ['class' =&gt; 'load-more'] ) ?&gt;&lt;?php Pjax::end(); ?&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is action in Sitecontroller:</p> <pre><code>public function actionInner($action = '', $a = 0) { $posts = Event::find()-&gt;limit(5 + $a*3)-&gt;all(); foreach ($posts as $post) { $post-&gt;price = $post-&gt;price - $post-&gt;price * $post-&gt;discount/100; } if ($action === 'name') { $posts = Event::find()-&gt;limit(5 + $a*3)-&gt;orderBy(['title' =&gt; SORT_ASC])-&gt;all(); foreach ($posts as $post) { $post-&gt;price = $post-&gt;price - $post-&gt;price * $post-&gt;discount/100; } } $news = Event::find()-&gt;limit(5 + $a*3)-&gt;orderBy(['date' =&gt; SORT_DESC])-&gt;all(); $populars = Event::find()-&gt;where(['is_popular'=&gt; 1])-&gt;limit(5 + $a*3)-&gt;orderBy(['likes' =&gt; SORT_DESC])-&gt;all(); return $this-&gt;render('inner',[ 'posts' =&gt; $posts, 'time' =&gt; date('H:i:s'), 'a' =&gt; $a, 'action' =&gt; $action ]); } </code></pre> </div>

将数据库连接到表单时出错,并给我以下错误

<div class="post-text" itemprop="text"> <p>I am try to fill the form and I got this error. Please someone tell me why?<br> I have attached all the code and the images: what I want is when I fill this form, it gets automatically saved in database. And please, if you can provide me how to upload images from the same form to the same database at <code>phpmyadmin</code>.</p> <p><strong>Error Message:</strong></p> <p><a href="https://i.stack.imgur.com/lTdnN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lTdnN.png" alt="enter image description here"></a></p> <p>This is the model :</p> <pre><code> class Clinic_Model extends CI_Model { function insert_into_db() { $pfn = $_POST['pfn']; $pe = $_POST['pe']; $pmn = $_POST['pmn']; $pa = $_POST['pa']; $pw = $_POST['pw']; $ph = $_POST['ph']; $pgt = $_POST['pgt']; $pbp = $_POST['pbp']; $pec = $_POST['pec']; $this-&gt;db-&gt;query("INSERT INTO add_clinic VALUES($pfn','$pe','$pmn','$pa','$pw','$ph','$pgt','$pbp','$pec')"); } } &lt;?php defined('BASEPATH') OR exit('No direct script access allowed'); </code></pre> <p>This is the controller</p> <pre><code>class Easyclinic extends CI_Controller { //----------Constructor---------- public function __construct() { parent::__construct(); $this-&gt;load-&gt;helper('url'); //load Model $this-&gt;load-&gt;model('clinic_model'); } //----------BaseFunctions---------- public function index() { $this-&gt;load-&gt;view('add_patient'); } public function mydata() { $this-&gt;load-&gt;view('mydata'); } public function addpatient() { $this-&gt;load-&gt;view('add_patient'); } //---------Advinced Functions--------- public function insert_into_db() { $this-&gt;load-&gt;model('clinic_model'); $this-&gt;clinic_model-&gt;insert_into_db(); $this-&gt;load-&gt;view('success');//loading success view } } </code></pre> <p>this is the view</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Add Patient&lt;/title&gt; &lt;!-- for-mobile-apps --&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;meta name="keywords" content="easyclinic" /&gt; &lt;script type="application/x-javascript"&gt; addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } &lt;/script&gt; &lt;!-- //for-mobile-apps --&gt; &lt;!-- //custom-theme --&gt; &lt;link href="assests/css/style.css" rel="stylesheet" type="text/css" media="all" /&gt; &lt;!-- js --&gt; &lt;script type="text/javascript" src="assests/js/jquery-2.1.4.min.js"&gt; &lt;/script&gt; &lt;!-- //js --&gt; &lt;link href='//fonts.googleapis.com/css? family=Roboto:400,100,300,500,700,900' rel='stylesheet' type='text/css'&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- banner --&gt; &lt;div class="center-container"&gt; &lt;div class="main"&gt; &lt;h1 class="w3layouts_head"&gt;Add Patient Info&lt;/h1&gt; &lt;h1 class="w3layouts_head"&gt;Welcome Dr.Atef&lt;/h1&gt; &lt;div class="w3layouts_main_grid"&gt; &lt;form action="&lt;?php echo base_url();? &gt;easyclinic/insert_into_db" method="post" class="w3_form_post"&gt; &lt;!-- day/time --&gt; &lt;div class="agileits_w3layouts_main_grid w3ls_main_grid"&gt; &lt;span class="agileinfo_grid"&gt; &lt;label&gt;Examination Date&lt;/label&gt; &lt;div class="agileits_w3layouts_main_gridl"&gt; &lt;input class="date hasDatepicker" id="datepicker" name="Text" type="text" value="dd/mm/yyyy" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '';}" required=""&gt; &lt;/div&gt; &lt;div class="agileits_w3layouts_main_gridr"&gt; &lt;input type="time" name="Time" placeholder=" " required=""&gt; &lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- name --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Patient Full Name &lt;/label&gt; &lt;input type="text" name="pfn" placeholder=" 4 part name" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- email --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Patient Email &lt;/label&gt; &lt;input type="text" name="pe" placeholder=" Email" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- Phone number --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Patient Number &lt;/label&gt; &lt;input type="text" name="pmn" placeholder="Phone Number" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- choose your Gender--&gt; &lt;div class="content-w3ls"&gt; &lt;div class="form-w3ls"&gt; &lt;div class="content-wthree2"&gt; &lt;div class="grid-w3layouts1"&gt; &lt;div class="w3-agile1"&gt; &lt;label&gt;Gender&lt;/label&gt; &lt;ul&gt; &lt;li&gt; &lt;input type="radio" id="a-option" name="pg"&gt; &lt;label for="a-option"&gt;Male &lt;/label&gt; &lt;div class="check"&gt;&lt;/div&gt; &lt;/li&gt; &lt;li&gt; &lt;input type="radio" id="b-option" name="pg2"&gt; &lt;label for="b-option"&gt;female&lt;/label&gt; &lt;div class="check"&gt;&lt;div class="inside"&gt;&lt;/div&gt;&lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- age --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Patient Age &lt;/label&gt; &lt;input type="text" name="pa" placeholder="Patient Age" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- weight --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Weight&lt;/label&gt; &lt;input type="text" name="pw" placeholder="Weight in KiloGrams" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- Height --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Height&lt;/label&gt; &lt;input type="text" name="ph" placeholder="Height in CentiMeters" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- Glucose --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Glucose Test&lt;/label&gt; &lt;input type="text" name="pgt" placeholder="~100~140" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- Heart pressure --&gt; &lt;div class="w3_agileits_main_grid w3l_main_grid"&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Blood Pressure&lt;/label&gt; &lt;input type="text" name="pbp" placeholder="~120~180" required=""&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- Uoload File --&gt; &lt;div&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Upload sonar image&lt;/label&gt; &lt;form method="post" enctype="multipart/form-data" action="upload"&gt; &lt;/br&gt; Choose a file: &lt;input type="image" name="usi" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;!-- Uoload File --&gt; &lt;div&gt; &lt;span class="agileits_grid"&gt; &lt;label&gt;Upload cbc image&lt;/label&gt; &lt;form method="post" enctype="multipart/form-data" action="upload"&gt; Choose a file: &lt;input type="image" name="uci" /&gt; &lt;input type="submit" /&gt; &lt;/form&gt; &lt;/div&gt; &lt;!-- day/time --&gt; &lt;div class="agileits_w3layouts_main_grid w3ls_main_grid"&gt; &lt;span class="agileinfo_grid"&gt; &lt;label&gt;Expectation of Childbirth&lt;/label&gt; &lt;div class="agileits_w3layouts_main_gridl"&gt; &lt;input class="date hasDatepicker" id="datepicker" name="Text" type="text" value="mm/dd/yyyy" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = '';}" required=""&gt; &lt;/div&gt; &lt;div class="agileits_w3layouts_main_gridr"&gt; &lt;input type="time" name="pec" placeholder=" " required=""&gt; &lt;/div&gt; &lt;div class="clear"&gt; &lt;/div&gt; &lt;/span&gt; &lt;/div&gt; &lt;!-- submit button --&gt; &lt;div class="w3_main_grid"&gt; &lt;div class="w3_main_grid_right"&gt; &lt;input type="submit" name="save" value="Submit"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;!-- Calendar --&gt; &lt;link rel="stylesheet" href="assests/css/jquery-ui.css" /&gt; &lt;script src="js/jquery-ui.js"&gt;&lt;/script&gt; &lt;script&gt; $(function() { $( "#datepicker" ).datepicker(); }); &lt;/script&gt; &lt;!-- //Calendar --&gt; &lt;div class="w3layouts_copy_right"&gt; &lt;div class="container"&gt; &lt;p&gt;© 2018 Patient Registration Form. All rights reserved | &lt;a href="http://w3layouts.com"&gt;HassanAli&lt;/a&gt;&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- //footer --&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and this is the image of phpmyadmion: <a href="https://i.stack.imgur.com/olR7m.png" rel="nofollow noreferrer">see phpmyadmin iamge</a></p> </div>

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

总结了 150 余个神奇网站,你不来瞅瞅吗?

原博客再更新,可能就没了,之后将持续更新本篇博客。

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

外包程序员的幸福生活

今天给你们讲述一个外包程序员的幸福生活。男主是Z哥,不是在外包公司上班的那种,是一名自由职业者,接外包项目自己干。接下来讲的都是真人真事。 先给大家介绍一下男主,Z哥,老程序员,是我十多年前的老同事,技术大牛,当过CTO,也创过业。因为我俩都爱好喝酒、踢球,再加上住的距离不算远,所以一直也断断续续的联系着,我对Z哥的状况也有大概了解。 Z哥几年前创业失败,后来他开始干起了外包,利用自己的技术能...

优雅的替换if-else语句

场景 日常开发,if-else语句写的不少吧??当逻辑分支非常多的时候,if-else套了一层又一层,虽然业务功能倒是实现了,但是看起来是真的很不优雅,尤其是对于我这种有强迫症的程序"猿",看到这么多if-else,脑袋瓜子就嗡嗡的,总想着解锁新姿势:干掉过多的if-else!!!本文将介绍三板斧手段: 优先判断条件,条件不满足的,逻辑及时中断返回; 采用策略模式+工厂模式; 结合注解,锦...

深入剖析Springboot启动原理的底层源码,再也不怕面试官问了!

大家现在应该都对Springboot很熟悉,但是你对他的启动原理了解吗?

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

2020阿里全球数学大赛:3万名高手、4道题、2天2夜未交卷

阿里巴巴全球数学竞赛( Alibaba Global Mathematics Competition)由马云发起,由中国科学技术协会、阿里巴巴基金会、阿里巴巴达摩院共同举办。大赛不设报名门槛,全世界爱好数学的人都可参与,不论是否出身数学专业、是否投身数学研究。 2020年阿里巴巴达摩院邀请北京大学、剑桥大学、浙江大学等高校的顶尖数学教师组建了出题组。中科院院士、美国艺术与科学院院士、北京国际数学...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

你期望月薪4万,出门右拐,不送,这几个点,你也就是个初级的水平

先来看几个问题通过注解的方式注入依赖对象,介绍一下你知道的几种方式@Autowired和@Resource有何区别说一下@Autowired查找候选者的...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《Oracle Java SE编程自学与面试指南》最佳学习路线图2020年最新版(进大厂必备)

正确选择比瞎努力更重要!

《Oracle Java SE编程自学与面试指南》最佳学习路线图(2020最新版)

正确选择比瞎努力更重要!

字节跳动面试官竟然问了我JDBC?

轻松等回家通知

面试官:你连SSO都不懂,就别来面试了

大厂竟然要考我SSO,卧槽。

终于,月薪过5万了!

来看几个问题想不想月薪超过5万?想不想进入公司架构组?想不想成为项目组的负责人?想不想成为spring的高手,超越99%的对手?那么本文内容是你必须要掌握的。本文主要详解bean的生命...

自从喜欢上了B站这12个UP主,我越来越觉得自己是个废柴了!

不怕告诉你,我自从喜欢上了这12个UP主,哔哩哔哩成为了我手机上最耗电的软件,几乎每天都会看,可是吧,看的越多,我就越觉得自己是个废柴,唉,老天不公啊,不信你看看…… 间接性踌躇满志,持续性混吃等死,都是因为你们……但是,自己的学习力在慢慢变强,这是不容忽视的,推荐给你们! 都说B站是个宝,可是有人不会挖啊,没事,今天咱挖好的送你一箩筐,首先啊,我在B站上最喜欢看这个家伙的视频了,为啥 ,咱撇...

立即提问
相关内容推荐