Jquery AJAX风格上传器
早上好。我的脚本正在这里运行: 这是一个ajax风格的上传程序 我的问题是: 上载图像时,它会调用已上载图像的刷新列表 但一旦刷新一次,“获取高度和宽度”功能就不再工作 Firebug返回: 代码: 代码: 这是我的密码: act.uploader.iframe.js 代码:Jquery AJAX风格上传器,jquery,ajax,upload,Jquery,Ajax,Upload,早上好。我的脚本正在这里运行: 这是一个ajax风格的上传程序 我的问题是: 上载图像时,它会调用已上载图像的刷新列表 但一旦刷新一次,“获取高度和宽度”功能就不再工作 Firebug返回: 代码: 代码: 这是我的密码: act.uploader.iframe.js 代码: //JavaScript文档 $(文档).ready(函数(){ var pageContents=$(“body”).html(); 函数getHeightAndWidth(){ self.parent.$(“#get
//JavaScript文档
$(文档).ready(函数(){
var pageContents=$(“body”).html();
函数getHeightAndWidth(){
self.parent.$(“#getHeightWidth”).bind(“单击”,函数(){
var dir=“getHeightAndWidth.php”;//要编写脚本的目录
var image=self.parent.$(“#imageSelect:selected”).text();
self.parent.$(“input[class=userInput2],select,#getHeightWidth”).attr('disabled',true);
self.parent.$(“#getError”).html(“正在收集数据,请稍候…”;
$.ajax({
类型:“POST”,
网址:dir,
数据:“图像=”+图像,
cache:false,
超时:30000,
错误:函数(){
self.parent.$(“#getError”).html(我们目前有大量用户,正在降低系统速度。请稍后再试。”;
self.parent.$(“输入[class=userInput2],选择,#getHeightWidth”).removeAttr('disabled');
},
成功:函数(html){
self.parent.$(“#heightAndWidthWrapper”).html(html);
self.parent.$(“输入[class=userInput2],选择,#getHeightWidth”).removeAttr('disabled');
}
});
});
self.parent.$(“#uploaderIframe”).remove();
}
函数buttonConvert(){//此函数可用于任何您希望更易访问的页面。将所有type=“submit”转换为type=“button”
self.parent.$(“输入[type=submit]”)。每个(函数(){
var buttonClassFind=$(this.attr(“类”);
如果(按钮CLASSFIND!=“离开”)
{
var inputButton=$(此);
var newInputButton=$('').insertBefore(inputButton);
inputButton.remove();
}
});
}
函数refreshImages(){
self.parent.$(“#sizeOptionsWrapper”).html(“刷新…”);
$.ajax({
url:'function.loadImages.php',
cache:false,
超时:30000,
错误:函数(){
self.parent.$(“#sizeOptionsWrapper”).html(“我们目前有大量用户,正在降低系统速度。请稍后再试。”;
self.parent.$(“#uploaderIframe”).remove();
},
成功:函数(html){
self.parent.$(“#sizeOptionsWrapper”).html(html);
按钮转换();
getHeightAndWidth();
}
});
}
self.parent.$(“#uploadResult”).html(页面内容);
刷新图像();
});
act.uploader.js
代码:
//JavaScript文档
$(文档).ready(函数(){
window.name=“main”;
函数上传(){
$(“#上传提交”).bind(“单击”,函数(){
var结果=“”;
$(“#上传程序”).append(结果);
$(“#uploadResult”).html(“正在上载,请稍候…”);
});
}
函数getHeightAndWidth(){
$(“#getHeightWidth”).bind(“单击”,函数(){
var dir=“getHeightAndWidth.php”;//要编写脚本的目录
var image=$(“#imageSelect:selected”).text();
$(“输入[class=userInput2],选择,#getHeightWidth”).attr('disabled',true);
$(“#getError”).html(“正在收集数据,请稍候…”;
$.ajax({
类型:“POST”,
网址:dir,
数据:'图像='+图像,
cache:false,
超时:30000,
错误:函数(){
$(“#getError”).html(“我们目前有大量用户,并且正在降低系统速度。请稍后再试。”;
$(“输入[class=userInput2],选择,#getHeightWidth”).removeAttr('disabled');
},
成功:函数(html){
$(#heightAndWidthWrapper”).html(html);
$(“输入[class=userInput2],选择,#getHeightWidth”).removeAttr('disabled');
}
});
});
}
函数buttonConvert(){//此函数可用于任何您希望更易访问的页面。将所有type=“submit”转换为type=“button”
$(“输入[type=submit]”)。每个(函数(){
var buttonClassFind=$(this.attr(“类”);
如果(按钮CLASSFIND!=“离开”)
{
var inputButton=$(此);
var newInputButton=$('').insertBefore(inputButton);
inputButton.remove();
}
});
}
按钮转换();
上传();
getHeightAndWidth();
});
如果需要的php或html让我知道
非常感谢您的帮助 您似乎没有在任何地方定义“self”——这是完整的代码吗?完整的java脚本是的。它似乎不会影响任何其他部分(在该功能下)。。。你知道怎么定义吗。。不是window.name=“main”;定义它?act.uploader.iframe.js-在iframe act.uploader.js中加载-在主页中加载Ohh,忽略我-不知道window.self宽恕;-)不是很好的jquery和ajax。。。试着学习,因为我需要它,经过进一步的测试,似乎一旦iframe被删除,功能不再工作。。。
self.parent is null
var image = self.parent.$("#imageSelect :selected").text();
// JavaScript Document
$(document).ready(function () {
var pageContents = $("body").html();
function getHeightAndWidth() {
self.parent.$("#getHeightWidth").bind("click", function () {
var dir = "getHeightAndWidth.php"; //directory to script
var image = self.parent.$("#imageSelect :selected").text();
self.parent.$("input[class=userInput2], select, #getHeightWidth").attr('disabled', true);
self.parent.$("#getError").html('<p>Gathering data please wait... <img src="loader.gif" /></p>');
$.ajax({
type: "POST",
url: dir,
data: 'image=' + image,
cache: false,
timeout:30000,
error: function () {
self.parent.$("#getError").html("<p>We are currently have a large volume of users and are slowing down our system. Please try again later.</p>");
self.parent.$("input[class=userInput2], select, #getHeightWidth").removeAttr('disabled');
},
success: function (html) {
self.parent.$("#heightAndWidthWrapper").html(html);
self.parent.$("input[class=userInput2], select, #getHeightWidth").removeAttr('disabled');
}
});
});
self.parent.$("#uploaderIframe").remove();
}
function buttonConvert() { // this function can be used on any page you want to make more accessible. Turns all type="submit" into type="button"
self.parent.$("input[type=submit]").each(function () {
var buttonClassFind = $(this).attr("class");
if (buttonClassFind!="leave")
{
var inputButton = $(this);
var newInputButton = $('<input type="button" id="' + inputButton.attr('id') + '" name="' + inputButton.attr('name') + '" class="' + inputButton.attr('class') + '" value="' + inputButton.val() + '" rel="' + inputButton.attr('rel') + '"/>').insertBefore(inputButton);
inputButton.remove();
}
});
}
function refreshImages() {
self.parent.$("#sizeOptionsWrapper").html('<p>refreshing... <img src="loader.gif" /></p>');
$.ajax({
url: 'function.loadImages.php',
cache: false,
timeout:30000,
error: function () {
self.parent.$("#sizeOptionsWrapper").html("<p>We are currently have a large volume of users and are slowing down our system. Please try again later.</p>");
self.parent.$("#uploaderIframe").remove();
},
success: function (html) {
self.parent.$("#sizeOptionsWrapper").html(html);
buttonConvert();
getHeightAndWidth();
}
});
}
self.parent.$("#uploadResult").html(pageContents);
refreshImages();
});
// JavaScript Document
$(document).ready(function () {
window.name = "main";
function upload() {
$("#uploadSubmit").bind("click", function () {
var results = '<iframe name="uploader" id="uploaderIframe"></iframe>';
$("#uploader").append(results);
$("#uploadResult").html('<p>Uploading please wait... <img src="loader.gif" /></p>');
});
}
function getHeightAndWidth() {
$("#getHeightWidth").bind("click", function () {
var dir = "getHeightAndWidth.php"; //directory to script
var image = $("#imageSelect :selected").text();
$("input[class=userInput2], select, #getHeightWidth").attr('disabled', true);
$("#getError").html('<p>Gathering data please wait... <img src="loader.gif" /></p>');
$.ajax({
type: "POST",
url: dir,
data: 'image=' + image,
cache: false,
timeout:30000,
error: function () {
$("#getError").html("<p>We are currently have a large volume of users and are slowing down our system. Please try again later.</p>");
$("input[class=userInput2], select, #getHeightWidth").removeAttr('disabled');
},
success: function (html) {
$("#heightAndWidthWrapper").html(html);
$("input[class=userInput2], select, #getHeightWidth").removeAttr('disabled');
}
});
});
}
function buttonConvert() { // this function can be used on any page you want to make more accessible. Turns all type="submit" into type="button"
$("input[type=submit]").each(function () {
var buttonClassFind = $(this).attr("class");
if (buttonClassFind!="leave")
{
var inputButton = $(this);
var newInputButton = $('<input type="button" id="' + inputButton.attr('id') + '" name="' + inputButton.attr('name') + '" class="' + inputButton.attr('class') + '" value="' + inputButton.val() + '" rel="' + inputButton.attr('rel') + '"/>').insertBefore(inputButton);
inputButton.remove();
}
});
}
buttonConvert();
upload();
getHeightAndWidth();
});