php - Jquery Get all the array elements -


i programming beginner..

code

 <script type="text/javascript">      $(function() {        var course_category = "<?php echo $_request['cities'] ?>";        alert(course_category); // alerts array    }); 

when print_r in php (print_r($cities);)

  array ( [0] => blr [1] => del [2] => hyd [3] => mum 

now want print array in above jquery

try

 $.each(course_category, function(key,value){    alert(value);   }}; 

printns a,r,r,a,y

the correct way use json:

var list = <?php echo json_encode($_request['cities']); ?>; 

Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -