1
I am doing a search in the database and returning this data in a table via ajax, there is in this same table a column that has a link that returns more information about the data, all this by ajax. The first ajax request happens as expected, but the second request the data appears and disappear from the screen quickly, I noticed that because I put an Alert in ajax.responseText. My question is whether I can execute two ajax requests on the same page. My js code is this Aki.
function mostrar_fase()
{
ajax = xmlhttp();
id_fase = document.getElementById('id_fase').value;
if(ajax)
{
ajax.open("GET",'http://localhost/sac/Ajax/mostrar_fase/' + id_fase, true);
ajax.onreadystatechange = function()
{
if (ajax.readyState == 4 && ajax.status == 200)
{
document.getElementById("resposta").innerHTML = ajax.responseText;
}
}
ajax.send();
}
}
The impression I have is that I must reset some variable in the first ajax request. I don’t know what else it would be. This code I posted is from the second request, but the first is very similar to this only changes a variable and the link. Thank you since.
You can use as many ajax calls as you want. What you need to decide is where the content goes, what you send to the server (and how that conditions the response) and how to display the content. Right now you’re overwriting the element
#resposta
is that what you want? and you don’t need to send your data to the specific call?– Sergio
#reply represents a div that I have in html code menu and I want to rewrite, the data I need is consulted in the data group by the page that is in ajax.open, and the query data is returned as I need, because I put an Alert in my code to verify it. The problem is that the data appears and then disappears from the screen.
– user3061295
What are you calling that function
mostrar_fase()
?– Sergio
is inside a table column, thus <td><a href="" onclick="Return mostrar_fase()" class="Tiny button">Show more</a></td>
– user3061295
If you look at Speed Tools how often the ajax is called? Does it match sometimes you want? it is difficult to guess without having an example of the problem... can you make a jsFiddle with the problem? or at least with your code?
– Sergio