Avatar of Puneet Arora
Puneet Arora
Flag for India asked on

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 2 of the JSON data

Here is my javascript code

<script type="text/javascript">
      
$(document).ready(function(){
	 $(location).attr('href');
     
		$('#myddl1').change(function(){
			 
  		var fk_i_id = $('#myddl1').val().trim();
		if(fk_i_id != 0)
		{ 
				alert(fk_i_id);
			 	
			$.ajax({
				 type:'POST',
				 url:'http://localhost/data/performa/index.php/Testing/getCatB?id='+fk_i_id,
				 datatype: 'json',
				  data: {id:fk_i_id},
				  
				  success: function(data){
				  var opts = $.parseJSON(data);
					alert(data);
				  
				  
				 $('#myddl2').empty();
				$.each(opts, function(i, d) {

					  $('#myddl2').append('<option value="' + d.pk_i_sub_id + '">' + d.s_name + '</option>');
                });


				
				} 

			 
         



			});
		}
	})
})
        



            
            </script>
  

 

Open in new window

JavaScriptjQueryJSON

Avatar of undefined
Last Comment
Puneet Arora

8/22/2022 - Mon
SOLUTION
Rob

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
hielo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Rob

Well spotted hielo :)
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Puneet Arora

ASKER
Found the solution after  study of the data coming from database
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23