2013-04-26 1 views
0

저는 여러 웹 브라우저에서 AJAX가 올바르게 작동하도록하는 이상한 문제가 있습니다. 특히 필요한 것들이 있습니까? 아니면 어떤 일이 원활하게 진행되도록하려면 어떤 트릭이 있습니까? 나는 데 첫 번째 문제는 다음과 함께AJAX Broswer 문제

, 그것은 크롬에서 완벽하게 작동하지만, 모든 IE와 파이어 폭스에서 아무것도하지 않는다 :

function DeleteRideshare(pid){ 
    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari 
     xmlhttp=new XMLHttpRequest(); 
    } 
    else{// code for IE6, IE5 
     xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    }   
    // Verify 
    var conf = confirm("Are you sure you want to delete this rideshare?"); 
    if(conf == true){ 
     xmlhttp.open("POST","updaterideshare.php",true); 
     xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); 
     xmlhttp.send("delete=true&PostID="+pid);  
     location.reload();      
    }   
} 

나는 또한이 있고, 크롬에서 일부 요소와 함께 작동 , 그리고 전혀 아니에요 및 파이어 폭스 :

$(document).ready(function(){ 
    $("#EditRideshareAjax").submit(function(){ 
     // Stop the from from submiting normally 
     event.preventDefault();   

     // get the values from the elements on the page 
     var values = $(this).serialize(); 

     $.ajax({ 
      type: "POST", 
      url: "updaterideshare.php", 
      data: values, 
      success:  function(msg){           
       location.reload(); 
      }, 
      error:function(){ 
       alert("An error has occured, please try again"); 
      } 
     }); 
    }); 
}); 

어떤 도움이나 통찰력을 주시면 감사하겠습니다! 감사!

+0

여기서 정확히 문제가 무엇입니까? – Joseph

+0

Firefox에서 ajax 요청을 제출하면 아무 일도 일어나지 않습니다. 그렇지만 크롬을 사용할 때 완전히 작동합니다. – user1875195

+1

@ user1875195 : 요청이 작동하는지 여부를 콘솔에서 확인 했습니까? 어쩌면 요청에 포함되지 않은 일부 논리에 문제가있을 수 있습니다. – Zeta

답변

1

함수에서 인수로 이벤트를 전달한 다음 사용하지 마십시오.

  $("#EditRideshareAjax").submit(function(event){