0
아약스 요청의 결과를 요청한 것과 동일한 페이지에 게시하고 싶습니다. JQuery와의아약스를 사용하여 같은 페이지에 다시 게시하십시오.
AJAX이 여기에 변수 설정하도록되어
var ids = 1
$(document).ready(function(){
$('#showbtn').on('click', function() {
$.ajax({
url: "http://localhost:3000/teamplayers.json",
data: {'resolution':ids},
type:"post",
dataType: "json",
cache: true,
success:function(){
$('#test3').val(1);
alert("test 3");
},
error: function(error) {
alert("Failed " + console.log(error) + " " + error)
}
});
});
});
:
# GET /teamplayers
# GET /teamplayers.json
def index
@teamplayers = Teamplayer.all
@fteams = Fteam.all
@teamplayer2 = 1
tid = params[:resolution] <-It should set here per the data section above
@ids = tid
end
불행히도는이 부분을 호출 Teamplayer 컨트롤러를 여기에 상호 작용하는 부분은 같은 컨트롤러
# POST /teamplayers
# POST /teamplayers.json
def create
@teamplayer = Teamplayer.new(teamplayer_params)
respond_to do |format|
if @teamplayer.save
format.html { redirect_to @teamplayer, notice: 'Teamplayer was successfully created.' }
format.json { render action: 'show', status: :created, location: @teamplayer }
else
format.html { render action: 'new' }
format.json { render json: @teamplayer.errors, status: :unprocessable_entity }
end
end
end
그럼 같은 페이지에 게시하려면 어떻게해야합니까?
을하지만 난 가져 오기를 수행 할 때,이 페이지의 끝에있는 데이터 페이지를 호출
이 같은 시도 . http : // localhost : 3000/teamplayers/1 – user3240928
@ user3240928 이것을 반영하는 답변이 업데이트되었지만'resolution'을 쿼리 문자열로 전달해야합니다. 논의. – mellowfish
ok 이제 값을 전달한다는 것을 알지만 정수로 값을 전달하는 방법 – user3240928