unable to write javascript inside the php page -


i have written javascript inside php file, while calling main page

     <script type="text/javascript" src="<?php echo base_url() . 'js/inf-scroll/javascript_showuserinst.php' ?>"> </script> 

problem: if see in javascript_showuserinst.php file line $.post('/instruction/show_user_inst/<?php echo $userid; ?>', { here <?php echo $userid; ?> giving me problem. line syntax correct?

i see view source showing <b>notice</b>: undefined variable: userid in <b>d:\xampp\htdocs\js\inf-scroll\javascript_showuserinst.php</b> on line <b>46</b><br />

but if copy & paste same js content in main page without calling external file, works perfectly.

javascript_showuserinst.php

header("content-type: application/javascript");  ?>   (function($) {          $.fn.scrollpagination = function(options) {                  var settings = {                          nop     : 10, // number of posts per scroll loaded                         offset  : 0, // initial offset, begins @ 0 in case                         error   : 'no more data display!', // when user reaches end message                                                     // displayed. can change if want.                                       .............                                      ............. 

javascript files expected contain javascript.

your javascript file contains fragment of html.

don't include html <script> tags in javascript file.


Comments

Popular posts from this blog

php - mySql Join with 4 tables -

css - Text drops down with smaller window -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -