2011-12-26 15 views
0

jQueryを使用するのは非常に新しいので、さらに読み込みをクリックしたときにページ上の投稿を更新するスクリプトがあります。 ChromeとFirefoxでは正常に動作しますが、IEでは何も起こりません。なぜ誰が知っていますか?関数を呼び出すボタンのjQueryとAjaxを使用するとIEエラーが発生する

jQueryのスクリプト

function get(){ 
$("#acomment").empty().html('<img src="design/ajax-loader.gif" />'); 
$.post('loadmore.php', {id: document.form.id.value, number: counter, kind: document.form.kind.value}, 
    function(output){ 
     $('#acomment').html(output).show(); 
     counter+=5; 
     $(document).ready(function() { 
     $('html, body').animate({ scrollTop: $('#scrollspot').offset().top }, 1000); 
     }); 
    }); 

}

スクリプト:

<form name="form" id="form" style='margin-top:10px'> 
<input type="hidden" name="kind" value="<?php echo $kind; ?>" /> 
<input type="hidden" name="id" value="<?php echo $name; ?>" /> 
<input type="button" value="Load More" onClick="get()" style='width:35%' /> 

それが機能していないでしょうなぜ?私はトラブルが少しshootedてきたし、問題はloadmore.phpページに関係していない

例: http://www.redarcadegames.com/topic/256

+0

変更フォーム以外に、フォームのID、時々はJavaScriptが混乱になるだろう。 – Virendra

答えて

0

この変更してみてください:

$.post('loadmore.php', {id: document.form.id.value, number: counter, kind: document.form.kind.value}, 

へ:

$.post(
    'loadmore.php', 
    { 
     id: $("#form input[name='id']").val(), 
     number: counter, 
     kind: $("#form input[name='kind']").val() 
    }, 

と削除:

$(document).ready(function() { 

ので、あなたの全体のコードは次のとおりです。

function get(){ 
    $("#acomment").empty().html('<img src="design/ajax-loader.gif" />'); 
    $.post(
     'loadmore.php', 
     { 
      id: $("#form input[name='id']").val(), 
      number: counter, 
      kind: $("#form input[name='kind']").val() 
     }, 
     function(output){ 
      $('#acomment').html(output).show(); 
      counter+=5; 
      $('html, body').animate({ scrollTop: $('#scrollspot').offset().top }, 1000); 
     } 
    ); 
}; 
+0

うーん...私はコードを交換するとすぐに、すべてのブラウザで一斉に動作しなくなりました。 –

+0

okこれはカンマではありませんでした。 '$("#form input [name = 'id'] '')val() ''、 '< - ' number:counter、 ' – andlrc

+0

他のブラウザーは動作を停止しましたが、Internet Explorerを修正しませんでした:/アクションのリンクが役立ちますか? http://www.redarcadegames.com/topic/256 –

関連する問題