Показать сообщение отдельно
  #9 (permalink)  
Старый 01.10.2015, 23:55
Новичок на форуме
Отправить личное сообщение для ggyyvv Посмотреть профиль Найти все сообщения от ggyyvv
 
Регистрация: 01.10.2015
Сообщений: 8

вот то что отвечает за форму
var interval;
	var $upload="uploaded.php";
			
			function applyAjaxFileUpload(element) {
				$(element).AjaxFileUpload({
					action: $upload,
					onChange: function(filename) {
						// Create a span element to notify the user of an upload in progress
						var $span = $("<span />")
							.attr("class", $(this).attr("id"))
							.text("Uploading")
							.insertAfter($(this));
						
						$(this).remove();

						interval = window.setInterval(function() {
							var text = $span.text();
							if (text.length < 13) {
								$span.text(text + ".");
							} else {
								$span.text("Uploading");
							}
						}, 200);
					},
					onSubmit: function(filename) {
						// Return false here to cancel the upload
						
						// Return key-value pair to be sent along with the file
						return true;
					},
					onComplete: function(filename, response) {
						window.clearInterval(interval);
						var $span = $("span." + $(this).attr("id")).text(filename + " "),
							$fileInput = $("<input />")
								.attr({
									type: "file",
									name: $(this).attr("name"),
									id: $(this).attr("id")
								});

						if (typeof(response.error) === "string") {
							$span.replaceWith($fileInput);

							applyAjaxFileUpload($fileInput);

							alert(response.error);

							return;
						}

						$("<a />")
							.attr("href", "#")
							.text("x")
							.bind("click", function(e) {
								$span.replaceWith($fileInput);

								applyAjaxFileUpload($fileInput);
							})
							.appendTo($span);
					}
				});
			}

			applyAjaxFileUpload("#demo1");

тут вроде все только то что отвечает за вывод названия файла в форме

я так понимаю мне нужно где то здесь вставить что-то такое?

var cart_id = document.getElementById('cartiid').value;;

						$.ajax({
							type: "POST",
							url: "uploaded.php",
							data: { cartiid: cart_id}
						}).done(function( msg ) {
						alert( "Data Saved: " + msg );
						});


var cart_id = document.getElementById('cartiid').value;; - вставляю в начале
а оставшуюся часть после onSubmit: function(filename) {

тогда я получаю ответ от сервера
{"name":"130","error":"\u0424\u0430\u0439\u043b \u043d\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0435
\u043d."} (error: Файл не загружен.)

то есть значение вроде бы попадает в пхп, но название файла все так же не меняется

Последний раз редактировалось ggyyvv, 02.10.2015 в 00:15.
Ответить с цитированием