I have PHP AJAX code that should check some parameters sent by jQuery and return some values. Currently, it is returning jQuery error calls in sequence, and I'm not sure why.
Here is my jQuery code:
$('.vote_up').click(function() { alert ( "test: " + $(this).attr("data-problem_id") ); problem_id = $(this).attr("data-problem_id"); var dataString = 'problem_id='+ problem_id + '&vote=+'; $.ajax({ type: "POST", url: "/problems/vote.php", dataType: "json", data: dataString, success: function(json) {
and here is the PHP code. Validation errors in PHP occur, but I see no indication that the error that occurs on the php side is the one that causes the jQuery error case.
This is the fragment that is called:
if ( empty ( $member_id ) || !isset ( $member_id ) ) { error_log ( ".......error validating the problem - no member id"); $error = "not_logged_in"; echo json_encode ($error); }
But how do I get "not_logged_in" so that it appears in my jQuery JavaScript, so that I know that this is the bit that was returned? And if this is not the case, how can I make this error return to jQuery?
Thanks!
source share