1 Replies - 208 Views - Last Post: 01 September 2017 - 10:32 AM

#1 JeremyBenson11  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 230
  • Joined: 10-January 14

ajaxForm issue

Posted 01 September 2017 - 06:30 AM

Hello,

I have two forms on a single page, both outputted based on different $_GET variables, but never at the same time. The video form works, but the image form doesn't. Both do the same thing, but the image form is giving me a 404 error. I'm not sure why, I've double checked the url, the script exists and seems to be named properly. They're both in the same folder, so not hard to detect. Aside from the code does anyone no how to return the url, so I can see where it's being sent. responseURL doesn't exist in jquery xhr object.

jquery
$(document).ready(function(){
		alert("Document Ready called");
		$(function() {
			
			alert("function prepare video form");
		// ajax form for video form
		$('#videoform').ajaxForm({
			beforeSend: function() {
				
				document.getElementById('progress').style.visibility='visible';
				document.getElementById('progress').style.display='block'; 
				document.getElementById('uploaderror').style.visibility='hidden';
				document.getElementById('uploaderror').style.display='none'; 
				
			},
			uploadProgress: function(event, position, total, percentComplete) {
				
				document.getElementById('progress').setAttribute('value', percentComplete);

			},
			complete: function(xhr) {
				
			},
			success: function(data){
			
				// uploaded: todfksjflkdjf
				// Error: file size too big
				
				if(data.indexOf( "uploaded:") > -1 && data.indexOf("Error:") <= -1)
				{
				     
					var token = data.split(":");
					token[1] = token[1].trim();
					
					// load view page with current token
					alert("gathered token");
					window.location = "../channel/view.php?token="+token[1];
				
				}else if(data.indexOf("Error:") > -1 && data.indexOf( "uploaded:") <= -1)
				{
					
					document.getElementById('uploaderror').style.visibility='visible';
					document.getElementById('uploaderror').style.display='block'; 
					document.getElementById('progress').style.visibility='hidden';
					document.getElementById('progress').style.display='none'; 
					
					document.getElementById('uploaderror').innerHTML = data;
					
				}
				
			}
		});
		
		$('#imageform').ajaxForm({
			
			beforeSend: function() {
				
				document.getElementById('progress').style.visibility='visible';
				document.getElementById('progress').style.display='block'; 
				document.getElementById('uploaderror').style.visibility='hidden';
				document.getElementById('uploaderror').style.display='none'; 
				
			},
			uploadProgress: function(event, position, total, percentComplete) {
				
				document.getElementById('progress').setAttribute('value', percentComplete);

			},
			complete: function(xhr) {
				alert(xhr.responseText);
			},
			success: function(data){
			
				// uploaded: todfksjflkdjf
				// Error: file size too big
			   alert(data);
			
				
			}
		});

		// end of function
	}); 
	
	// end of document ready function	
});



html for images form
<div id="videos" style="width:60%;">	
											<span class="block" style="margin-top:0.5em;"><b>Upload Image</b></span>
											<form id="videoform" role="form" action="../php/upload_image.php" method="post" enctype="multipart/form-data">
												<input id="upload_file[]" type="file" name="upload_file[]"  />
												<div class="form-group" style="margin-top:0.5em;">
													<label class="block">Title</label>
													<input type="text" name="title" />
												</div>
												<div class="form-group">
													<label>Caption</label>
													<textarea id="aboutfield" class="block" type="text" name="caption" rows="8" maxlength="250"></textarea>
												</div>
												<div class="form-group">
													<label>Liscence</label>
													<select id="aboutfield" class="block" type="text" name="license" rows="8">
														<option value="Copyright, all rights reserved">Copyright, all rights reserved</option>
														<option value="Cretive Commons: CC0">Cretive Commons: CC0</option>
														<option value="Cretive Commons: BY">Cretive Commons: BY</option>
														<option value="Cretive Commons: BY-SA">Cretive Commons: BY-SA</option>
														<option value="Cretive Commons: BY-NC">Cretive Commons: BY-NC</option>
														<option value="Cretive Commons: BY-ND">Cretive Commons: BY-ND</option>
														<option value="Cretive Commons: BY-NC-SA">Cretive Commons: BY-NC-SA</option>
														<option value="Cretive Commons: BY-NC-ND">Cretive Commons: BY-NC-ND</option>
													</select>
												</div>		
											    <span id="uploaderror"></span>
												<progress id="progress" value="0" max="100"></progress>
												<input class="block special-button-left" type="submit" value="Upload" />
											</form>
										</div>


HTML form element from video form, although probably not needed.

<form id="videoform" role="form" action="../php/upload_video.php" method="post" enctype="multipart/form-data">


This is all the error I'm getting, lol. Jquery isn't being descriptive at all:

Quote

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.


The link referring page in the browser is the page the form is on.

This post has been edited by JeremyBenson11: 01 September 2017 - 06:38 AM


Is This A Good Question/Topic? 0
  • +

Replies To: ajaxForm issue

#2 ArtificialSoldier  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1789
  • View blog
  • Posts: 5,700
  • Joined: 15-January 14

Re: ajaxForm issue

Posted 01 September 2017 - 10:32 AM

Use your developer tools, the network tab should show every request being sent.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1