小编Lan*_*kea的帖子

使用ajax请求获取上一个和下一个对象

我正在尝试创建一个Ajax函数,它将根据创建日期创建文章导航,因此用户可以使用以前(较旧)和下一个(较新)链接浏览文章.

<div class="content clear">

  <div class="article">
    Article contents...
  </div>

  <a href="#Prev" id="prev" class="leftarrow" title="Previous">EELMINE<span class="arrow_left"></span></a>
  <a href="#"     id="bactolist" onClick="history.go(-1); return false;">Tagasi nimekirja juurde<span class="arrow_middle"></span></a>
  <a href="#Next" id="next" class="rightarrow" title="Next">JÄRGMINE<span class="arrow_right"></span></a>
</div> <!-- End content -->

<script type="text/javascript">

$.ajax({
  url: '/admin/api/site/articles.json?per_page=100',
  dataType: 'json',
  success: function(articles) {
    $(articles).each(function(index, article) {

      console.log(article);

      $('div.article').fadeOut(0);        
      $('div.article:first').fadeIn(500);  
      $('a.leftarrow, a.rightarrow').click( function (ev) {

        //prevent browser jumping to top
        ev.preventDefault();

        //get current visible item
        var $visibleItem = $('div.article:visible');

        //get total item count
        var total =  $('div.article').length;

        //get index …
Run Code Online (Sandbox Code Playgroud)

html javascript ajax jquery pagination

6
推荐指数
1
解决办法
2812
查看次数

未定义的属性:DOMDocument::$tagName

我在 WP 的 debug.log 文件中收到以下错误。

PHP 注意:未定义属性:DOMDocument::$tagName 在 .../wp-content/themes/theme-name/libs/oi/functions.php 第 441 行

PHP 注意:尝试在第 441 行的 .../wp-content/themes/theme-name/libs/oi/functions.php 中获取非对象的属性

function oi_display_hierarchy( $nav_menu, $args )
{
    if( ! is_single() )
    {
        return $nav_menu;
    }

    $menuXML = new SimpleXMLElement( $nav_menu );
    list($current) = $menuXML->xpath( "//li[contains(@class,'current-menu-parent')]" );
    if( !empty( $current ) )
    {
        $node = dom_import_simplexml($current);
        while($node)
        {
            $node = $node->parentNode;
            if( $node->tagName == 'li' ) // 441 - The problem line
            {
                $classes = $node->getAttribute('class');
                $node->setAttribute('class', $classes . ' current-menu-ancestor current-menu-parent current_page_parent current_page_ancestor'); …
Run Code Online (Sandbox Code Playgroud)

php wordpress

5
推荐指数
1
解决办法
3857
查看次数

canvas绘制图像循环问题

我正在尝试通过用图像替换 fillRect来修改这个画布游戏。

在spaceinvaders.js第 529 行更改船舶代码时没有问题:

ship = new Image();
ship.src = "images/ship.svg";

ctx.drawImage(ship, this.ship.x - (this.ship.width / 2), this.ship.y - (this.ship.height / 2), this.ship.width, this.ship.height);
Run Code Online (Sandbox Code Playgroud)

但遇到了入侵者循环的问题:

for(var i=0; i<this.invaders.length; i++) {

    var invader = this.invaders[i] = new Image();
    this.invaders[i].src = "images/space_invader.png";

    //ctx.fillRect(invader.x - invader.width/2, invader.y - invader.height/2, invader.width, invader.height);

    this.invaders[i].onload = function(){

        var thisX = invader.x * 18;
        var thisY = invader.y * 14;

        return function() {
            ctx.drawImage(invader,invader.x - invader.width/2, invader.y - invader.height/2, invader.width, invader.height);
            //ctx.drawImage(this, thisX, thisY, …
Run Code Online (Sandbox Code Playgroud)

javascript canvas

1
推荐指数
1
解决办法
3134
查看次数

显示HTML而不是浏览器警报

我有一个游戏的以下脚本:

 $(function() {
     $("#sortable").sortable({
         opacity: 0.6,
         cursor: 'move',
         update: function() {
             var winningString = "g01,g02,g03,g04,g05,g06,g07,g08,g09,g010,g011,g012,g013,g014,g015,g016";
             var currentString = '';
             $('#sortable li').each(function() {
                 var imageId = $(this).attr("id");
                 currentString += imageId.replace("recordArr_", "") + ",";
             });
             currentString = currentString.substr(0, (currentString.length) - 1);
             if (currentString == winningString) {
                 alert("Congratulations! You have completed the challenge.");
             }
             console.log(currentString);
         }
     });
 });
Run Code Online (Sandbox Code Playgroud)

现在我想要做的是显示HTML消息而不是浏览器警报.但我无法想象如何使用脚本的警报部分更改它,至少不会出现错误.

...添加$( "#message2" ).dialog();给出TypeError ...对话框不是一个函数

HTML消息:

<div id="message2" title="">
  <p>Congratulations! You have completed the challenge.</p>
</div>
Run Code Online (Sandbox Code Playgroud)

在我的脚本中有以下脚本<head>:

  • jquery.ui.core.js …

html javascript jquery jquery-ui

0
推荐指数
1
解决办法
101
查看次数

标签 统计

javascript ×3

html ×2

jquery ×2

ajax ×1

canvas ×1

jquery-ui ×1

pagination ×1

php ×1

wordpress ×1