기본적으로 버튼을 클릭 할 때 전체 페이지를 다시로드하면서 경고를 생성하려고합니다. 내가 버튼을 클릭하면 내 컨트롤러에레일에서 버튼을 클릭 할 때 Ajax 호출
:javascript
function ajax_test1(field)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET", "test_ajax.xml?code=" + field.value, false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
alert(xmlDoc.getElementsByTagName("message")[0].childNodes[0]);
}
및
= button_to 'test ajax', :remote => true, :onclick => "ajax_test1(this);"
이
def test_ajax
@test = {message:'Hello there!'}
render :xml => @test
end
페이지는 다음 URL로 다시로드 : 내보기에
http://localhost:4242/test?onclick=ajax_test1%28this%29%3B&remote=true
어떻게 해결할 수 있습니까?
'return false; '를 추가했지만 같은 결과를 얻었습니다. – Pol0nium