0

I am using this plugin for a voting system like stackoverflow: https://github.com/janosgyerik/jquery-upvote

But after i followed all instructions, Ajax call do not work !

Here my javascript code:

$(function() {

var callback = function(data) {
    alert("test1"); // <--------- ALERTED
    $.ajax({
        url: 'http://localhost/test.php',
        type: 'post',
        data: { id: data.id, up: data.upvoted, down: data.downvoted, star: data.starred },
         success: function(data) {
            alert("test2"); // <--------- NOT ALERTED
        }
    });
};
$('#topic').upvote({id: 123, callback: callback});
});

Html code:

 <div id="topic" class="upvote">
    <a class="upvote"></a>
    <span class="count">0</span>
    <a class="downvote"></a>
    <a class="star"></a>
 </div>

I get TEST1 alerted, but TEST2 don't !

Inside test.php i wrote only: echo "test"; // just for test and link is right and work well.

Better Fly
  • 23
  • 6
  • Add the error param to the ajax call (as success). i.e. : `error: function(jqXHR, textStatus, errorThrown) {console.log(textStatus, errorThrown);}` Then check your console for error. – JazZ Oct 13 '16 at 17:28
  • 1
    So check your console for error. – A. Wolff Oct 13 '16 at 17:28
  • I get the message `error` only ! i used it like this since i don't know where i find the console: `error: function(jqXHR, textStatus, errorThrown) {alert(textStatus, errorThrown);}` – Better Fly Oct 13 '16 at 17:39
  • 1
    [How can I debug my JavaScript code?](http://stackoverflow.com/questions/988363/how-can-i-debug-my-javascript-code) – A. Wolff Oct 13 '16 at 17:41
  • I got this error message: `Blocking a multi-origin request (Cross-Origin Request): the "Same Origin" policy does not refer to the remote resource on http: //localhost/test.php. Reason: CORS header "Access-Control-Allow-Origin"` – Better Fly Oct 13 '16 at 17:47

0 Answers0