#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    294
    Rep Power
    12

    I can't get rid of a zero from my output


    UPDATE: I figured it out, needed to add "die(1);" to my PHP script.

    I have created a live search form using AJAX and everything is working perfectly except my results end with a zero that I can't explain or get rid of.

    Here is my code:

    Code:
    // Live AJAX Search
    $(document).ready(function() {
    	
    	function search() {
    		var query_value = $('input#review-search').val();
    		var ajaxurl = '/ajax.php';
    		if(query_value !== ''){
    			$.ajax({
    				type: "POST",
    				url: ajaxurl,
    				data: { "action": "live-search", query: query_value },
    				success: function(html){
    					$("#category-post-content").html(html);
    				}
    			});
    		}
    	}
    	
    	$("input#review-search").live("keyup", function(e) {
    		// Set Timeout
    		clearTimeout($.data(this, 'timer'));
    	
    		// Set Search String
    		var search_string = $(this).val();
    	
    		// Do Search
    		if (search_string == '') {
    			$("#category-post-content").fadeOut();
    		}else{
    			$("#category-post-content").fadeIn();
    			$(this).data('timer', setTimeout(search, 100));
    		};
    	});
    });
    The code triggers a PHP script, but I know the problem isn't there because when I strip everything out of it and just echo "Hello World" the result is "Hello World0". I can't explain it or get rid of it.
    Last edited by bradbrevet; October 31st, 2013 at 11:56 PM.

IMN logo majestic logo threadwatch logo seochat tools logo