SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2005
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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?


    Code JavaScript:
     
    //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;
    	});

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,707
    Mentioned
    102 Post(s)
    Tagged
    4 Thread(s)
    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.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •