I’m having a problem with the inArray function not sure why. I’m passing a string back to the Javascript from my PHP it looks something like this 22,24 ect. I’ve tried using the split command to convert it to a Javascript array and I’ve tried it just as is. Either way the inArray function isn’t finding 22, I’ve tried 22 with and without speak marks in the inArray function.
$.ajax({
url: "<?=base_url(); ?>/products/update_dropdown/"+<?=$product['product_id']?>+"/"+strUser,
type: 'GET',
success: function(msg) {
var test;
test = $.inArray(22, msg);
alert(test);
}
});
Thank you for any help this is really driving me nuts!
So from your comments it looks like the problem is that there is whitespace before the number 22 in your string (
[" 22", "24"]).You can run:
See http://jsfiddle.net/KAdRD/ for a worked example.