Issue with $.post Jquery Script

I’m trying to build a AJAX function which generates a slug from a title text automatically similer to WordPress. I need to take the title make a AJAX call to the PHP Script which will return the slug back but I’m having issues with getting the Jquery to work at the moment.

I keep getting a error for reponse.get.getElementsByTagName is not a function but not sure why.

Any help?



//Generate Slug
	$('#news_title').bind('blur', function() {
		$.post("news.php", {
			action: "generateSlug",
			id: $(this).attr('rel'),
			term: $('#news_title').val()
		},  function(response) {
				if (response = (response.getElementsByTagName('response').length==1) ? response.getElementsByTagName('response')[0] : false) {
					if (response.getAttribute('status')=='failed') {
						alert('Not Worked');	
					} else if (response.getAttribute('status')=='success') {
						alert('Worked');	
					}
				}
		}, "text");
		return false;
	});

Have you confirmed what type of data is contained within the response variable?
If the mime-type from PHP isn’t correct, the response might be treated as if it were a string instead, which would explain the error that you’re getting.