Avatar of Puneet Arora
Puneet AroraFlag 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
SOLUTION
Avatar of Rob
Rob
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Rob
Rob
Flag of Australia image

Well spotted hielo :)
ASKER CERTIFIED SOLUTION
Avatar of Puneet Arora
Puneet Arora
Flag of India image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
Avatar of Puneet Arora
Puneet Arora
Flag of India image

ASKER

Found the solution after  study of the data coming from database
JavaScript
JavaScript

JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.

127K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo