Last active
August 29, 2015 14:02
-
-
Save alanerzhao/cc09a55ddbaec447b4c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define("feedback",["jquery"],function(require, exports, module){ | |
var $ = jquery = jQuery = require("jquery"); | |
$(function(){ | |
var addUploadBtn = $('.add-upload-btn'), | |
inputFile = $("#inputfile"), | |
loading = $(".loading"), | |
feedbackBtn = $(".jia-feedback-btn"), | |
message = $("#message"), | |
contactText = $(".jia-contact-info"); | |
checkInfo(); | |
function uploadImg () { | |
//点击添加图片 | |
addUploadBtn.click(function () { | |
inputFile.trigger("click"); | |
}) | |
//响应文件添加成功事件 | |
inputFile.change(function(){ | |
//创建FormData对象 | |
//var data = new FormData(); | |
//为FormData对象添加数据 | |
//$.each(inputFile[0].files, function(i, file) { | |
// data.append('upload_file'+i, file); | |
//}); | |
loading.show(); //显示加载图片 | |
//发送数据 | |
$.ajax({ | |
//上传接口 | |
url:'submit_form_process.php', | |
type:'POST', | |
data:data, | |
cache: false, | |
contentType: false, | |
processData: false, | |
success:function(data){ | |
loading.hide(); //加载成功移除加载图片 | |
}, | |
error:function(){ | |
alert('上传出错'); | |
loading.hide(); //加载失败移除加载图片 | |
} | |
}); | |
}); | |
} | |
function checkInfo () { | |
feedbackBtn.click(function () { | |
var messageVal = $.trim(message.val()); | |
var contactTextVal = $.trim(contactText.val()); | |
if(messageVal == "" ) { | |
alert("请输入您的意见"); | |
return false; | |
} else if (contactTextVal == "") { | |
alert("请输入联系方式") | |
return false; | |
} | |
return true; | |
}) | |
} | |
}); | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment