-4

I want to concatenate these two string emp_name and emp_post. Suppose emp_name is joshi and emp_post is ldc.
I want to get joshi ldc

$('#emp_name').val(res.emp_name);
$('#emp_post').val(res.emp_post );

But I don't know how to concatenate these two string. My full Code is below:

<script>
$( document ).ready(function() {});
    function my_validate_func() {
    var emp_id = $('#emp_id').val();
        if ($('#emp_id').val() != "" ) {
            $.ajax({
            type: "POST",
            url: 'check_ccl.php',
            data: { emp_id: emp_id},
            success: function(response) {
            var res = $.parseJSON(response);
                $('#emp_name').val(res.emp_name);
                $('#emp_post').val(res.emp_post );
            }

        });
        }
    }
</script>
Shiladitya
  • 12,003
  • 15
  • 25
  • 38
Doni
  • 11
  • 2
  • 8
  • 1
    Possible duplicate of [JS strings "+" vs concat method](https://stackoverflow.com/questions/16124032/js-strings-vs-concat-method) – Alexander Aug 15 '18 at 16:45
  • Possible duplicate of [Most efficient way to concatenate strings in JavaScript?](https://stackoverflow.com/questions/16696632/most-efficient-way-to-concatenate-strings-in-javascript) – Dan Sp. Aug 15 '18 at 18:09

1 Answers1

2

in javascript you can use + for concatenate string

so

success: function(response) {
        var res = $.parseJSON(response);
            $('#emp_name').val(res.emp_name);
            $('#emp_post').val(res.emp_post );
          var my_res  =  res.emp_name + ' ' + res.emp_post;
          // you can se the result in console for test
          console.log(my_res); 
        }
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107