Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
77
rated 0 times [  84] [ 7]  / answers: 1 / hits: 43905  / 11 Years ago, thu, february 28, 2013, 12:00:00

I need to grab some data from a JSP page that does a select on a database and then put inside a div. I need to do this with ajax.



Here is my code:



$(function() {
teste();
});

function teste() {
var v1 = document.getElementById(selCodigo).value;
alert(v1);

$.ajax({
type : GET,
data : turma=+v1,
url : busca-notas.jsp,
success : function(resposta){
alert(DEU CERTO);
},
error : function(xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
document.getElementById(notas).innerHTML = ERRO;
}
});
}


I tested the variable v1 and the value that it receives necessary, and in my JSP page, I do this:



String turmaSelecionada = request.getParameter(turma);


the problem is that the ajax content that does not feed into the div need, beyond what the xhr.status presents thrownError and a 404 error not found



Can anyone help me?




More From » jquery

 Answers
9

Either, busca-notas.jsp does not exist, or it is on a different server or path as the HTML calling the Ajax request.



Example: If your HTML and JavaScript is here:



http://www.example.com/somepath/page.html


and your PHP code is here:



http://www.example.com/otherpath/busca-notas.jsp


then you'll Need to use url: ../otherpath/busca-notas.jps. There is an easy way to check: Open your HTML in the browser, remove the last bit of the path, and replace it with busca-notas.jpg, and see what you're getting.



A 404 also means, your JSP code never gets executed.


[#79920] Thursday, February 28, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
myrap

Total Points: 407
Total Questions: 105
Total Answers: 109

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
myrap questions
Tue, Feb 8, 22, 00:00, 2 Years ago
Wed, Jan 15, 20, 00:00, 4 Years ago
Thu, Oct 24, 19, 00:00, 5 Years ago
Thu, Oct 3, 19, 00:00, 5 Years ago
Mon, Aug 12, 19, 00:00, 5 Years ago
;