im new with laravel 4 며칠 전에 시작되었습니다. 내 문제는 간단합니다, 나는 클라이언트 또는 사용자가 변경하고 "부분"보기를 렌더링 콤보 상자 있습니다.Laravel 4 부분보기가있는 아약스
이 처음이다. 의 OnChange는 :
자바 스크립트를 통해 간단한 메시지를 렌더링
내가 "손으로"값을 배치 그것은 단지 부분보기가 표시됩니다 경우 내 문제는 다음과 같습니다
을컨트롤러의 내 기능입니다.
public function getTeste1() {
$id = Input::get('value');
if($id=="")
{
$this->layout->content = View::make('home.user');
}
else
{
$this->layout->content = View::make('home.user2')->with('ides',$id);
}
}
이 내 자바 스크립트 함수 :
이 내 부분이다<h1>Home</h1>
<p>Welcome to your Home. You rock!</p>
<form>
<select name="users" onchange="showCustomer(this.value)">
<option value="0">Select a person:</option>
<option value="1">Peter Griffin</option>
<option value="2">Lois Griffin</option>
<option value="3">Glenn Quagmire</option>
<option value="4">Joseph Swanson</option>
</select>
</form>
<div id="txtHint"></div>
:이 내이다
function showCustomer(str)
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
{
alert ("Your browser does not support AJAX!");
return;
}
var url="";
url="?value="+str;
//url=url+"&sid="+Math.random();
// alert(url);
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(true);
}
@if($ides!=0)
<div id="txtHint"> <b>Person info will be listed here -> {{ $ides }} </b></div>
@endif
내가이 문제를 왜 내가 아는, 내가 돈 너희들이 그것이 도움이 될거라는 것을 알고 있다면, 그것을 피하는 법을 알지 못한다.
는곤 칼로 모 우라 감사
편집 :
따라서, stateChanged 기능 :
function stateChanged()
{
if (xmlHttp.readyState==4)
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText;
// alert(document.getElementById("txtHint").innerHTML);
}
}
JQuery와 기능 내가 당신의 솔루션을 사용 경우는 다음과 같이 표시됩니다 :
<script>
$(document).ready(function() {
$("#users").change(function() {
$.get('http://localhost/LoginProject/public/home/teste1?value=' + $(this).val(), function(data) {
$("#txtHint").html(data);
});
});
});
</script>
'stateChanged' 기능을 표시 할 수 있습니까? –
명시된 추가 – Ratz