SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: AJAX Request

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX Request

    I am creating a site where I am using an ajax request. The user pastes the url of a video and the request gets the flash source for that video. Dailymotion works but YouTube does not. I think this may be due to the fact that YouTube has more than one get variable. Anyone know what to do. Here is my code...

    Request:
    Code:
    		<script type="text/javascript">  
    			/* ajax.Request */  
    			function ajaxRequest(url,data) {  
    				var aj = new Ajax.Request(  
    					url, {  
    						method:'get',  
    						parameters: data,  
    						onComplete: getResponse  
    					}  
    				);  
    			}  
    			/* ajax.Response */  
    			function getResponse(oReq) {  
    				$('Results').innerHTML = oReq.responseText;  
    			}  
    		</script>
    Form:
    Code:
    					<form action="" method="get">
    						URL:<input class="FormText" id="VideoURL" style="width: 300px;" type="text" value="<?php echo $url; ?>" />
    						<input class="FormSubmit" onClick="ajaxRequest('video_request.php', 'URL='+$F('VideoURL'))" type="button" value="Go" />
    					</form>
    Thanks for your time,
    HighCaliber

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2006
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It appears that if the user selects a site such as YouTube then they are trying to do a request like the following:
    Code:
    video_request.php?URL=http://youtube.com/watch?v=HBIW7As0nxM
    Could the problem lie within this request, such as the question mark within the YouTube link?

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quite possible, did you try
    Code:
    var aj = new Ajax.Request(  
    	url, {  
    		method:'get',  
    		parameters: encodeURIComponent(data),  
    		onComplete: getResponse  
    	}  
    );


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
  •