Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems sending info with ajax by post
    primarykey
    data
    text
    <p>I made a moderation script, voting up and down question and answers. Time ago the script worked, but when i came back to start coding in this project one more time, it doesn't work anymore.</p> <p>The script was doing: when you click in a div called vote, or vote1 a link, it ask if it's up or down. If it's up, it loads url: "mod_up_vote.php" sending by post some info about the question you are voting on. It was ok. But not now. It doesn't load that page, because i was printing and inserting in database the $_POST variable and nothing was there.</p> <p>What do you think is wrong here? Thanks.</p> <pre><code> $(document).ready(function() { $(document).delegate('.vote, .vote1', '.vote2', 'click', function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var dataString = 'id='+ id ; var parent = $(this); if(name=='mod_up') { $(this).fadeIn(200).html('&lt;img src="dot.gif" align="absmiddle"&gt;'); $.ajax({ type: "POST", url: "mod_up_vote.php", dataType: "xml", data: dataString, cache: false, success: function(xml) { //$("#mod-pregunta").html(html); //$("#mod-respuesta").html(html); //parent.html(html); $(xml).find('pregunta').each(function(){ var id = $(this).attr('id'); var pregunta = $(this).find('preguntadato').text(); var respuesta = $(this).find('respuestadato').text(); var votoup = $(this).find('votoup').text(); var votodown = $(this).find('votodown').text(); var id_pregunta = $(this).find('id_pregunta').text(); var id_respuesta = $(this).find('id_respuesta').text(); $("#mod-pregunta").html(pregunta); $("#mod-respuesta").html(respuesta); //$(".vote").attr('id', $(this).find('id_pregunta').text()); $(".vote1").html("&lt;a href=\"modera\" title=\""+ id_pregunta + "-"+ id_respuesta + "-1\" class=\"vote1\" id=\""+ id_pregunta + "-"+ id_respuesta + "-1\" name=\"mod_up\"&gt;Aceptar&lt;/a&gt;"); $(".vote2").html("&lt;a href=\"modera\" title=\""+ id_pregunta + "-"+ id_respuesta + "-2\" class=\"vote2\" id=\""+ id_pregunta + "-"+ id_respuesta + "-2\" name=\"mod_up\"&gt;Rechazar&lt;/a&gt;"); //$("span", this).html("(ID = '&lt;b&gt;" + this.id + "&lt;/b&gt;')"); }); } }); } return false; }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload