Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
i get this error wen i try running this script ...pls help


TypeError: invalid 'in' operand obj" // when i view the console



JavaScript
$.ajax ({
			url:'jen.php',
			datatype:'json',
			jsonp:'jsoncallback',
			timeout:5000,
			success:function(data, status){
				$('#sch').empty();
				alert('');
				
				$.each(data,function(index,item){
                                var rept = '<li>'+item.id+'</li>';
					$('#sch').append(rept);	
                }

				});
				
				
			},
			error:function(){
				$('#sch').empty();
				$('#sch').text('error occured');
				}
			});
Posted
Comments
Member 10202752 14-Dec-13 8:53am    
some shld help dis stuff is tearing ma head apart
I guess removing the below line might resolve the issue.

jsonp:'jsoncallback',
Peter Leow 14-Dec-13 9:43am    
try the following changes:

jsonpCallback: 'jsoncallback',
dataType: 'jsonp',
contentType: "application/json",
Member 10202752 15-Dec-13 9:18am    
THANKS GUYZ

1 solution

The way you used jsonp is wrong.Please check below mentioned link for more info.

$('document').ready(function() {
    var pm_url = 'http://twitter.com/status';
    pm_url += '/user_timeline/stephenfry.json';
    pm_url += '?count=10&callback=photos';
    $.ajax({
        url: pm_url,
        dataType: 'jsonp',
        jsonpCallback: 'photos',
        jsonp: 'callback',
    });
});
function photos (data) {
    alert(data);
    console.log(data);
};


Basic example of using .ajax() with JSONP

I hope this will help to you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900