0

I have tried (data = "") and various others but none seem to work.

$.ajax({
    url: "includes/peopleGoingList.php",
    type: "POST",
    dataType: "html",
    data: {"ID": eventID},
    success: function(data){
    console.log(data);

    if (data.length === 0) {
        $("#dialog-attendees").html("<p>No one is going.. :[</p>");
    } else {
        $("#dialog-attendees").html(data);
    }
});
3
  • I always return JSON with ['ok'] set to true if everything went well and check if (typeof data=='object' && data.ok) Commented Jan 1, 2014 at 21:49
  • I originally returned json but I want sure how to loop though all the json data so I decided to echo html data in the php file instead. Musa's answer worked so I will stick with it :) Commented Jan 1, 2014 at 21:57
  • Ok but FYI $json=array('ok'=>true, 'html'=>$thehtml); echo json_encode($json); die; and $("#dialog-attendees").html(data.html); Commented Jan 1, 2014 at 22:02

1 Answer 1

3

There are probably arbitrary white space in your output, try trimming it

if ($.trim(data) == '') {
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.