1

ajaxを使用して新しいHTML/JSコンテンツをロードし、それをdivブロックに追加しています

問題は、新しい(受信した)コードにいくつかの画像タグが含まれていて、ロード後にそれらが表示されないことです。画像のアドレスを直接コピーして確認すると、すべて問題ありません。

たとえば、受信したコードには次のものがあります。

<img srс="http://capitalpay.co.uk/images/vending/1.png" />

画像は直接正常に読み込まれますが、こちらのサンプルページをご覧ください

利用できません。たぶん、JSを使用して受信したコードに画像をプリロードする必要がありますか?


UPD

$.post('loadPage.php', {page: currentPage}, function(data) {
  $('#TextInside').html(data);
});

UPD2

応答:

<H2>Vending machine</H2>
The vending machine is designed to serve the participants in the system with the possibility of receiving and issuing banknotes.<br />

With the help of party system can:<br />
<p>
- Make purchases at any online store<br />
- Provide additional services and services provided by the system
</p>

With the help of an agent system can:<br />
<p>
- Register participants in the system<br />
- Make purchases at any online store<br />
- Provide additional services and services provided by the system.
</p>

<img srс="http://capitalpay.co.uk/images/vending/1.png" style="width: 50%; height: 50%" />

<div id="pageContainer" style="margin: 0 auto; width: 90%">
  <!-- Slideshow HTML -->
  <div id="slideshow">
    <div id="slidesContainer">
      <div class="slide">
        <h2>Web Development Tutorial</h2>
        <p><img srс="http://capitalpay.co.uk/images/vending/1.png" style="width: 50%; height: 50%" />
If you're into developing web apps, you should check out the tutorial called "<a href="http://sixrevisions.com/tutorials/web-development-tutorials/using-xampp-for-local-wordpress-theme-development/">Using XAMPP for Local WordPress Theme Development</a>" which shows you how to set up a local testing server for developing PHP/Perl based applications locally on your computer. The example also shows you how to set up WordPress locally!</p>
      </div>
      <div class="slide">
        <h2>Grunge Brushes, Anyone?</h2>
        <p><img srс="http://capitalpay.co.uk/images/vending/2.png" width="516" height="305" />In this layout, I used <a href="http://sixrevisions.com/freebies/brushes/sr-grunge-free-high-resolution-photoshop-grunge-brushes/">SR Grunge</a>, which is a free set of high-resolution Photoshop brushes you can download here on Six Revisions.</p>
        <p> 
      </div>
      <div class="slide">
        <h2>How About Some Awesome Grunge Textures?</h2>
        <p><img srс="http://capitalpay.co.uk/images/vending/3.png" width="516" height="305" />The texture used in this web page is from the Grunge Extreme Textures freebie set by JC Parmley released here on Six Revisions.</p>
        <p>You can head over to the <a href="http://sixrevisions.com/freebies/textures/grunge-extreme-15-high-resolution-grunge-textures/">Grunge Extreme</a> page to download the texture set or check out Six Revisions' <a href="http://sixrevisions.com/category/freebies/">freebie section</a> for even more goodies!</p>
      </div>
      <div class="slide">
        <h2>'Tis the End, My Friend.</h2>
        <p><img srс="http://capitalpay.co.uk/images/vending/4.png" width="516" height="305" />This is the last slide. Hit the left arrow control to go back to the other slides.</p>
        <p>Alternatively, you may want to check out the tutorial on how to create a simple and cool button in Photoshop called &quot;<a href="http://sixrevisions.com/tutorials/photoshop-tutorials/how-to-create-a-slick-and-clean-button-in-photoshop/">How to Create a Slick and Clean Button in Photoshop</a>&quot; which was inspired by the <a href="http://www.campaignmonitor.com/designer/?utm_source=sixrevisions&amp;utm_medium=banner&amp;utm_term=2&amp;utm_content=0003&amp;utm_campaign=Apr09Banners">Campaign Monitor</a> web interface.</p>
      </div>
    </div>
  </div>
  <!-- Slideshow HTML -->
</div>
<script language="javascript">
$(document).ready(function(){
  var currentPosition = 0;
  var slideWidth = 650;
  var slides = $('.slide');
  var numberOfSlides = slides.length;

  // Remove scrollbar in JS
  $('#slidesContainer').css('overflow', 'hidden');

  // Wrap all .slides with #slideInner div
  slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
    .css({
      'float' : 'left',
      'width' : slideWidth
    });

  // Set #slideInner width equal to total width of all slides
  $('#slideInner').css('width', slideWidth * numberOfSlides);

  // Insert controls in the DOM
  $('#slideshow')
    .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
    .append('<span class="control" id="rightControl">Clicking moves right</span>');

  // Hide left arrow control on first load
  manageControls(currentPosition);

  // Create event listeners for .controls clicks
  $('.control')
    .bind('click', function(){
    // Determine new position
        currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
    // Hide / show controls
    manageControls(currentPosition);
    // Move slideInner using margin-left
    $('#slideInner').animate({
      'marginLeft' : slideWidth*(-currentPosition)
    });
  });

  // manageControls: Hides and Shows controls depending on currentPosition
  function manageControls(position){
    // Hide left arrow if position is first slide
    if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
    // Hide right arrow if position is last slide
    if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
  } 
});
</script>

UPD

ええ、問題はにありましたsrc。ラテン語の「c」とシリル語の「c」は、キーボードの同じキーにあります。入力ミスだけ。

4

2 に答える 2

3

ページにコードをロードするときに、Tehreは画像をプリロードする必要はありません。

AJAXを使用してページにコードを含めることは問題ありません。HTMLコード自体に問題があります。

その画像タグをWebページに直接配置すると、次のいずれも読み込まれません。http: //jsfiddle.net/fNNG8/

タグのcinsrcに何か奇妙なことがあります。img削除して新しいものを書くだけなら、問題なく動作します。

于 2011-03-24T10:07:24.327 に答える
2

違いを見てください.....笑、ここにも

<?php

echo ord('с'); //this 'с' is copied from above text.

echo "<br/>";

echo ord('c');

結果

209
99
于 2011-03-24T10:18:57.543 に答える