0

I am using jQuery ajax and php to return some html content and echo it in my page. Content get returned successfully but it also includes number 1 at the end of response which I dont want. I guess its the same at this question: php include prints 1

Can I get rid of number 1 at the end because its visible in my page?

If I remove echo $content how do I return this to javascript where I use it?

$.ajax({
        type: 'POST',
        url: awp_data.ajax_url,
        data: ajax_data,
        dataType: 'text',   
    }).done(function(result) {
    
        activePreset.html(result);

        
        
    }).fail(function(jqXHR, textStatus, errorThrown) {
        console.log(jqXHR, textStatus, errorThrown);
    }); 
}

php

public function get_preset_custom_settings() {

        $result = dirname(__FILE__) . '/includes/preset_config/'.$_POST['preset'].'.php';
                
        $content = require($result);
        if ($content === false) {
            echo ('Failed to load preset settings!');
            exit;
        }

        echo $content;

        wp_die();
        
    }
Toniq
  • 4,492
  • 12
  • 50
  • 109

0 Answers0