0

HTML:

<div id="signUpError"></div>

JS:

<script type="text/javascript">
    function showSignUpError(message) {
        document.getElementById('signUpError').innerHTML="<div class='alert alert-danger'>"+message+"</div>";    
    }
</script>

PHP:

$error="this is error"

How to call showSignUpError($error)

VLS
  • 2,306
  • 4
  • 22
  • 17
Vibhor Roy
  • 11
  • 1
  • 2
    Welcome to Stack Overflow! Please be sure to provide sufficient details explaining your problem so that others can understand and help you find a solution. – Hayden Schiff Aug 07 '15 at 15:54

1 Answers1

0

Try this code:

showSignUpError(<?php echo $error; ?>);

Try that first, but it might be necessary to quote the text:

showSignUpError("<?php echo $error; ?>");

Note that this will only run once, on page load.

If you wish to call-out to the PHP code while interacting with user, then you should check out AJAX:

AJAX request callback using jQuery

Community
  • 1
  • 1
cssyphus
  • 37,875
  • 18
  • 96
  • 111