日期:2014-05-16 浏览次数:20674 次
$.ajax({
type: "get",
url: "/openshop/control/getCustomerAddress",
data:"customerId="+$.trim($("#customerId")[0].value),
cache: false,
success: function(msg){
$("#addressInfo")[0].innerHTML = msg;
showTipWindow(newid,oldid,0,e);
}
});
$('#'+newid+'_frmNewAddr').ajaxForm({ beforeSubmit: validate ,success: showResponse});
....
function validate(formData, jqForm, options){
var form = jqForm[0];
if (!form.new_recipient.value ) {
alert('收件人必须填写!');
return false;
}
if (!form.new_address.value ) {
alert('收件地址必须填写!');
return false;
}
....
return true;
}
function showResponse(responseText, statusText, xhr, $form){
var address = eval("("+removeDivTag(responseText)+")");
$("#address_recipient")[0].innerHTML = address.recipient;
$("#address_address")[0].innerHTML = address.address;
$("#address_organization")[0].innerHTML = address.organization;
......
}
<script type="text/javascript">
function ajaxFileUpload(imgName)
{
$("#loading")
.ajaxStart(function(){
$(this).show();
})
.ajaxComplete(function(){
$(this).hide();
});
$.ajaxFileUpload
(
{
url:'/productmgr/control/uploadProductImg',
secureuri:false,
fileElementId: imgName+'File',
dataType: 'text',
success: function (data, status)
{
data = removeDivTag(data);
if(data=="ImgEmptyErr"){
alert("请选择上传图片!");
return;
}
if(data=="sysErr"){
alert("上传失败,请重试!");
return;
}
$("#"+imgName)[0].value = data;
$("#"+imgName+"Div")[0].innerHTML = "上传成功!"
//alert($("#"+imgName)[0].value);
},
error: function (data, status, e)
{
alert("添加产品图片时发生如下错误:"+e);
}
}
)
return false;
}
</script>
/*
* 产品图片上传
*
* author : Emerson
*
* Yiihee , Inc. */
import org.ofbiz.base.util.*;
import org.ofbiz.base.util.string.*;
import org.ofbiz.entity.*;
import java.text.SimpleDateFormat;
import java.util.*;
import java.io.*;
import org.apache.commons.fileupload.disk.*;
import org.apache.commons.fileupload.servlet.*;
import org.apache.commons.fileupload.*;
configProperties = UtilProperties.getProperties("opencommon.properties");
String imageUploadServerPath = configProperties.get("openb2c.image.upload.server.path");
//SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
//Date date = new Date();
//String filename = sf.format(date);
String fileName;
File uploadPath = new File(imageUploadServerPath);//上传文件目录
if (!uploadPath.exists()) {
uploadPath.mkdirs();
}
// 临时文件目录
File tempPathFile = new File(imageUploadServerPath+"\\temp\\");
i