-1

Not working echo "<br/>"; in php showing the result with <br/>,there is no line break. Can any tell me why it's happening?

script.js

jQuery(document).ready(function(){
    
    jQuery('.form1').on('submit',function(){
        
        $.ajax({
            'url' : 'process.php',
            'success' : function(result){
                jQuery('.info').text(result);
            },
            'data': {
                'nam' : 'Ratul',
                'address' : 'Dhaka',
            },
            'type' : 'POST'
        });
        return false;
    });
    
});

process.php

<?php

$name = $_POST['nam'];
$address = $_POST['address'];


echo "Name:".$name;
echo "<br />";
echo "Address:".$address;
Community
  • 1
  • 1

3 Answers3

2

In your Javascript you're using jQuery('.info').text(result);

This takes "result" and prints it directly as text. What you most likely want to do is jQuery('.info').html(result); This will print it properly with html tags rendering.

Link
  • 76
  • 1
  • 11
1

Use html(result) instead text(result)

jQuery(document).ready(function(){

    jQuery('.form1').on('submit',function(){

        $.ajax({
            'url' : 'process.php',
            'success' : function(result){
                jQuery('.info').html(result);
            },
            'data': {
                'nam' : 'Ratul',
                'address' : 'Dhaka',
            },
            'type' : 'POST'
        });
        return false;
    });

});
Pushpendra Kumar
  • 1,721
  • 1
  • 15
  • 21
0

How about this? "\r\n" instead of using <br>

echo "Name:".$name."\r\n";
echo "Address:".$address."\r\n";
Jesper Martinez
  • 611
  • 5
  • 15