jquery - How to use model int array variable in javascript MVC 4 -


model

public int[] mobileid{get;set;} 

script

var k; for(var i=0;i<3;i++) {   k=@model.mobileid[i];   alert(k); } 

this method not working,how assign int array variable javascript var. use below method:

var k=[]; k=@html.raw(json.encode(model.mobileid));//not work 

you can convert model.mobileid string separator of choice , convert javascript array:

<script>     var k = "@(model.mobileid == null ? string.empty : string.join(",", model.mobileid))";     alert(k);     k = k.split(",");     k // k array @ point </script> 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -