Exemplo n.º 1
0
			$(".J_logout").live("click", function() {
				$.ajax({
					type : 'GET',
					url : G.API.WEB_LOGOUT,
					success : function(data) {
						/*if (data.status == "success") {
							window.location = G.PAGE.LOGIN;
						}

						store.clear();*/
					}
				});
				$.ajax({
					type : 'GET',
					url : G.API.LOGOUT,
					success : function(data) {
						if (data.status == "success") {
							window.location = G.PAGE.LOGIN;
						}

						store.clear();
					}
				});
				return false;
			});
Exemplo n.º 2
0
            return function(e) {
                var $btn=$(e.currentTarget);
                if(!$btn.hasClass('disabled')) {

                    var that=this,
                    val=$btn[0].tagName=="INPUT"?"val":'html',
                    data=fn.call(this,e);

                    if(!data) return;

                    $btn.data('val',$btn[val]())
                    $btn.addClass('disabled')[val]("请稍候..."||msg);

                    $.ajax({
                        url: bridge.url(data.url),
                        type: data.type||'POST',
                        dataType: data.dataType||'json',
                        data: data.data,
                        success: function(res) {
                            data.success&&data.success.call(that,res);
                        },
                        error: (data.error||function(res) {
                            tip((res&&res.msg)||"网络错误");
                        }),

                        complete: function() {
                            $btn.removeClass('disabled')[val]($btn.data('val'));
                        }
                    });
                }
            }
Exemplo n.º 3
0
		loadData : function(params) {
			var grid = this;
			var autoRender = this.get("autoRender");
			var model = this.get("model");
			if (model)
				return;
			if (autoRender) {
				var url = this.get("url");
				$.ajax({
					type : 'GET',
					url : url,
					success : function(data) {
						grid.setModel(data);
						if (parent) {
							parent.seajs.emit("event_grid_loaded");
						} else {
							seajs.emit("event_grid_loaded");
						}
					},
					error : function() {
					},
					dataType : 'json',
					data : params
				});
			}
		},
Exemplo n.º 4
0
		$("#GoodsWall .ilike-del").off().on("click",function(){
			var $delBtn = $(this),
			$goodsItem = $delBtn.parents(".goods"),
			productId = $delBtn.data("proid"),
			ajaxUrl ="/theme/removeGoods",
			ajaxData = {
				themeId: parseInt(UserTheme.themeId),
				goodsId: parseInt(productId)
			};
			$.ajax({
				   url: ajaxUrl,
                type:"post",
                contentType:"application/json; charset=utf-8",
                dataType:"json",
                data:JSON.stringify(ajaxData),
				   success: function(data){
					   switch(data.code){
					       case("100"):
						       $goodsItem.addClass("goods-gray");
						       break;
					       case("101"):
						       alert(data.message);
					   }  
				   }
			});
		});
Exemplo n.º 5
0
Arquivo: form.js Projeto: nolure/nojs
		ajaxSubmit : function(){
		    //ajax提交表单
		    var self = this,
		    options = $.extend({
		        url : this.form[0].action,
		        //data : this.form.serialize(),
		        type : 'post',
		        dataType : 'json',
		        context : this
		    }, this.options.ajaxSubmit),
		    _success = options.success;
		    
		    options.success = function(json){
		        self.state = null;
                _success && _success.call(this, json);  
		    }
            var bs = options.beforeSend;
            if( typeof bs=='function' && bs()==false ){
                self.state = null;
                return;
            }
            if( bs ){
                delete options.beforeSend;
            }
            options.data = this.form.serialize();

		    //dataType:'jsonp'跨域提交 get使用jquery默认处理方式 post使用iframe提交
		    if( options.dataType=='jsonp' && options.type=='post' ){
		        form.post(this.form, options);
		    }else{
		        $.ajax(options);
		    }
		    
		}
Exemplo n.º 6
0
 customSearch : function(data) {
     window.console && console.log('request:', data);
     var _self = this;
     this.ajaxLoadingBox.show();
     this.async = $.ajax({
         url : 'searchings.json',
         type : 'POST',
         data : data,
         cp: _self.cp++,
         //timeout : 10000,
         success : function(resp) {
           //  console.log('response:', resp);
             if (resp.stat == 'ok') {
                 _self.ajaxLoadingBox.hide();
                 _self.dataDispatch(resp);
             } else
                 _self.emit('FORM:SYSTEMERROR');
         },
         error : function(xhr, stat, error) {
             _self.ajaxLoadingBox.hide();
             _self.emit('FORM:SYSTEMERROR');
             window.console && console.log('error: ', xhr, stat, error);
         }
     });
 }
Exemplo n.º 7
0
            'change .js_province': function(e) {
                var value=e.currentTarget.value,
                    $city=this.$('.js_city'),
                city=$city[0];
                city.options.length=0;

                if(!value) {
                    city.options.add(new Option('',""));
                } else {
                    city.options.add(new Option('正在载入...',""));

                    $.ajax({
                        url: app.url('/json/region?action=city&provid='+value),
                        dataType: 'json',
                        success: function(res) {
                            city.options[0].text=('请选择');
                            $.each(res.data,function(i,item) {
                                city.options.add(new Option(item.name,item.id));
                            });
                        },
                        error: function(res) {
                            city.options[0].text=(res&&res.msg||'网络错误');
                        }
                    });
                }
            },
Exemplo n.º 8
0
											function(event) {
												if ($(this).hasClass("init")) {
													var url=G.API.CODENAME;
													var param = "";
													if(item.alias){
														param = item.type=="select" ? $(".J-"+item.alias).find("option:selected").val() : $(".J-"+item.alias).val();
													}else{
														if(item.filter){
															param = item.filter;
														}
													}
													$.ajax({
														url : url,
														data:{
															"key":item.options,
															"param":param
														},
														success : function(data) {
															if (!data.message) {
																var html = "";
																var items = data.items;
																var template = handlebars
																		.compile("{{#tree this}}{{/tree}}");
																var html = template(items);
																$(".J-"+ item.name).append(html).removeClass("init");
															} else {
																Log.error(data.message);
															}
														}
													});
												}
											});
Exemplo n.º 9
0
				method : function() {
					if (validateModuel()) {
						$.ajax({
							type : 'POST',
							url : G.API.MODULE_UPDATE,
							dateType : 'json',
							data : $('#form-module-update').serialize(),
							success : function(data) {
								if (data.moduleId && data.moduleName) {
									Notice.show($('body'), '修改成功');
									var tree = $.fn.zTree.getZTreeObj(treeId);
									// var newTreeNode =
									// parseModule2TreeNode(data);
									treeNode.name = data.moduleName;
									$.extend(treeNode.data, data);
									tree.updateNode(treeNode);
									Dialog.close();
								}
								if (data.message && data.detail) {
									Notice.show($('#module-grid'), '<span style="color:red;">保存失败</span>');
									Dialog.close();
								}
							}
						});
					}
					return false;
				}
Exemplo n.º 10
0
				method : function() {
					// 提交请求
					if (validateResource()) {
						$.ajax({
							type : "POST",
							url : G.API.RESOURCE_INSERT,
							dateType : "json",
							data : $('#form-resource-add').serialize(),
							success : function(data) {
								if (data.resourceCode && data.resourceName) {
									// seajs.emit(G.EVENT.RESOURCE_QUERY);
									Notice.show($('#resource-grid'), '添加成功');
									grid.query($('#form'));
									Dialog.close();
								} else {
									if (data.detail && data.message) {
										Notice.show($('#resource-grid'), '<span style="color:red;">' + data.message + '</span>');
										Dialog.close();
									}
								}
							}
						});
					}
					return false;
				}
Exemplo n.º 11
0
	Translator.prototype.reload = function (bAdmin, sLanguage, fDone, fFail)
	{
		var
			self = this,
			$html = $('html'),
			fEmptyFunction = function () {},
			iStart = (new Date()).getTime()
		;

		$html.addClass('rl-changing-language');

		$.ajax({
				'url': require('Common/Links').langLink(sLanguage, bAdmin),
				'dataType': 'script',
				'cache': true
			})
			.fail(fFail || fEmptyFunction)
			.done(function () {
				_.delay(function () {
					self.reloadData();
					(fDone || fEmptyFunction)();
					$html.removeClass('rl-changing-language');
				}, 500 < (new Date()).getTime() - iStart ? 1 : 500);
			})
		;
	};
Exemplo n.º 12
0
			confirm : function() {
				var selected = grid.getSelectedData();
				var pks = [];
				$(selected).each(function(i, item) {
					pks.push(item.resourceId);
				});
				$.ajax({
					type : "POST",
					url : G.API.RESOURCE_DELETE,
					dateType : "json",
					data : {
						pks : pks.join(',')
					},
					success : function(data) {
						if (data.detail && data.message) {
							Notice.show($('#resource-grid'), '<span style="color:red;">' + data.message + '</span>');
							Dialog.close();
						} else {
							Dialog.close();
							Notice.show($('#resource-grid'), '删除成功');
							grid.query($('#form'));
						}
					}
				});
				return false;
			},
Exemplo n.º 13
0
		loadData:function(){		
			var that = this;
			//null则表示增加
			if(this.get("para")){
				$.ajax({
					type : "POST",
					async : false,
					url : G.API.RESOURCE_QUERY,
					data : {
						pkRes : this.get("para")
					},
					dateType : "json",
					success : function(data) {
						if(that.get("para")!=null){
							var dataModel ={};
							var userView = data.records[0];
							if(userView!=null){
								dataModel["resourceId"] =  userView.resourceId;
								dataModel["url"] = userView.url||"";
								dataModel["resourceCode"] =  userView.url||"";
								dataModel["resourceName"] = userView.resourceName||"";
								dataModel["securityLevel"] = userView.securityLevel||"";
								dataModel["moduleId"] = userView.moduleId||"";
								dataModel["seq"] = userView.seq||"";
							}
							that.setModel(dataModel);
						}
					}
				});
			}
		},
Exemplo n.º 14
0
    delegate.on('click', '.JS-trigger-download-video', function(element){
        var flag;
        var checkUrl = $(element.target).data('url');

        $.ajax({
            url: checkUrl,
            type: 'POST',
            data: {},
            cache: false,
            async: false
        }).done( function (res) {
            if(!res.hasError && res.content && res.content.isSuccess){
               return true;
            }else{
                if(res.content && res.content.message){
                    Modal.alert(0, res.content.message);
                }else{
                    Modal.alert(0, "系统繁忙,请联系管理员");
                }
                if ( element && element.preventDefault )          
                    element.preventDefault();      
                else          
                    window.event.returnValue = false; 
                return false; 
            };
        });
    });
Exemplo n.º 15
0
 base: function(params) {
     var obj = $.extend({}, params || {});
     if(!obj.before || (obj.before && obj.before() !== false)) {
         obj.dataType = 'json';
         obj.type = params.type || 'GET';
         obj.success = function(data) {
             if(rule(data, obj, 'success')) { // 成功
                 if(params.success) {
                     params.success(data);
                 }
             } else if(rule(data, obj, 'permission')) { // 无权限
                 $.isFunction(params.permission) ? params.permission(data) : config.noPermissionAction();
             } else { // 服务端判定失败
                 $.isFunction(params.error) ? params.error(data) : config.errorAction(data);
             }
         };
         obj.error = function(xhr, status) {
             if(status !== 'abort') { // 主动放弃,这种一般是程序控制,不应该抛出error
                 $.isFunction(params.error) ? params.error(xhr, status) : config.errorAction(xhr, status);
             }
         };
         obj.complete = function(xhr, status) {
             if($.isFunction(params.complete)) {
                 params.complete(xhr, status);
             }
         };
         obj.contentType = 'application/json';
         return $.ajax(obj);
     }
 },
Exemplo n.º 16
0
				method : function() {
					// 提交请求
					if (validateModuel()) {
						$.ajax({
							type : 'POST',
							url : G.API.MODULE_INSERT,
							dateType : 'json',
							data : $('#form-module-add').serialize(),
							success : function(data) {
								if (data.moduleId && data.moduleName) {
									// seajs.emit(G.EVENT.RESOURCE_QUERY);
									Notice.show($('body'), '添加成功');
									Dialog.close();
									$.fn.zTree.getZTreeObj(treeId);
									tree.addNodes(treeNode, {
										id : data.moduleId,
										pId : data.parentId,
										name : data.moduleName,
										data : data
									});
								} else {
									if (data.detail && data.message) {
										Notice.show($('body'), '<span style="color:red;">' + data.message + '</span>');
										Dialog.close();
									}
								}
							}
						});
					}
					return false;
				}
Exemplo n.º 17
0
		loadData : function() {
			var that = this;
			$.ajax({
				type : 'GET',
				url : G.API.CREDIT,
				dataType : 'json',
				success : function(data) {
					if (data) {
						for(var i=0;i<data.length&&i<10;i++){
							if(data[i].productLines==null||data.productLines==""){
								data[i].productLines="全部产品线";
							}
						}
						if (data.length > 10) {
							that.setModel({
								records: data.slice(0, 10),
								notempty:true
							});
						} else {
							that.setModel({
								records:data,
								notempty:true
							});
						}
					}else{
						that.setModel("没有信用额度数据");
					}
				},
				error:function(response) {
					that.setModel("查询信用额度失败");
				}
			});
		},
Exemplo n.º 18
0
	/**
	 * 从服务器端获取当前用户已经拥有的标签
	 */
	function init(options) {
		$.ajax({
			url : G.API.ACCOUNT_FAVORITE_TAGS,
			success : function(data) {
				if (data) {
					var tagMap = data;
					var tags = [];
					var counter = 0;
					for (var tag in tagMap) {
						if (counter++ < options.maxTagCount) {
							tags.push(tag);
						}
					}
					
					var html = handlebars.compile(template)(tags);
					$(options.renderTo).html(html);
					
					// TODO 从这里增加使用例子
					// 增加交互处理
					addEffect();
				} else {
					throw new Error('没有获取到当前用户的标签信息');
				}
			}
		});
	}
Exemplo n.º 19
0
        tmpl: function(/*name[,url][,data]*/) {
            var that=this,
                args=slice.apply(arguments),
                i=0,
                name=args[i++],
                url=args[i++],
                data=args.pop();

            template=that.getTemplate(name);

            if(typeof url==='string') {
                var dfd=$.Deferred();
                $.ajax({
                    url: url,
                    data: data,
                    dataType: 'json',
                    type: 'post',
                    success: function(res) {
                        dfd.resolveWith(that,[tmpl(template,res)]);
                    },
                    error: function() {
                        dfd.reject();
                    }
                });
                return dfd.promise();

            } else {
                return tmpl(template,data);
            }
        },
Exemplo n.º 20
0
		loadData:function(){		
			var that = this;
			//null则表示增加
			if(this.get("para")){
				$.ajax({
					type : "POST",
					async : false,
					url : G.API.MEANUS_QUERY,
					data : {
						pkMenu : this.get("para")
					},
					dateType : "json",
					success : function(data) {
						if(that.get("para")!=null){
							var dataModel ={};
							var userView = data.records[0];
							if(userView!=null){
								dataModel["menuId"] =  userView.menuId;
								dataModel["menuTitle"] =  userView.menuTitle;
								dataModel["parentId"] =  userView.parentId;
								dataModel["resourceId"] = userView.resourceId||"";
								dataModel["seq"] = userView.seq||"";
								dataModel["hide"] = userView.hide=='Y'?true:false;
								dataModel["leaf"] = userView.leaf=='Y'?true:false;
							}
							that.setModel(dataModel);
						}
					}
				});
			}
		},
Exemplo n.º 21
0
 show: function() {
   var that = this;
   if (!robotReady) {
     robotReady = true;
     $.ajax(URLCONFIG.roboturl, {
       dataType: 'json'
     }).success(function(data) {
       if (data.stat != 'ok') {
         Robot.superclass.show.call(that);
         robotReady = false;
         return;
       }
       robotReady = true;
       // this.model 的值
       // ---------------
       // isLogin 是否登录
       // isComplete 补全信息(支付密码): true
       // isBindedMobile 手机绑定: false
       // isCertified 实名认证: true
       // securityLevel 安全等级: LOW,MEDIUM,HIGH,MAX
       // fpCount 快捷卡数量
       // questions 安保问题: 0,1,3
       // activedEmail 激活的邮箱:T,F
       $.extend(that.model, {isSuccess: true}, data);
       that.renderPartial('.global-robot');
     }).error(function() {
       robotReady = false;
     });
   }
   Robot.superclass.show.call(that);
   return this;
 }
Exemplo n.º 22
0
 confirmOk: function(e) {
   e.preventDefault();
   var msgId = $(this.currentConfirmMsg).parent().attr('data-id');
   this.$('#global-msg-confirm').hide();
   setMsgRead.call(this, this.currentConfirmMsg);
   $.ajax(URLCONFIG.readmessage + msgId, {dataType: 'json'});
 },
Exemplo n.º 23
0
    $(function(){
        UserTheme.init();
        ThemeDiscuss.init()
        $.ajax({
            url: "/theme/getComments",
            type : "GET",
            dataType:"html",
            data:{themeId:parseInt($("#J_themeId").val())},
            success: function(data){
                $("#J_commentList").append(data);
            }
        });
        $(document).on("click","a.commentPage",function(){
            var p =$(this).data("page");
            var themeId = $(this).data("themeid");
            $.ajax({
                url:"/theme/getComments?themeId="+themeId+"&p="+p,
                type:"get",
                dataType:"html",
                success:function (data) {
                    $("#J_commentList").html(data)
                }})
        })





        /*  分享 */
        $(".btn-share").shareToThird()
    })
Exemplo n.º 24
0
		var tempSaveOrder = function() {
			
			// 订单行不能为空
			if (!validator.product()) {
				return false;
			}
			
			var option = {
				title : "提交订单",
				content : "正在暂存订单,请稍后......"
			};
			dialog.loading(option);
			var viewData = $("#orderAddForm").serialize();
			$.ajax({
				url : G.API.ORDER_TEMPSAVE,
				type : "POST",
				data : viewData,
				success : function(orderView) {
					if (orderView.message) {
						dialog.close();
						dialog.alertMsg("请添加收货地址和商品后暂存!");
					} else {
						afterOrderTempSave(orderView);
					}
				},
				error : function() {
					dialog.alertMsg("添加商品失败,请重试!");
				}
			});
			return false;
		};
Exemplo n.º 25
0
 //加载表情 ajax
 function _add_ajax(){
     $.ajax({
         url: options.emotionSrc,
         type: 'GET',
         dataType: 'json',
         timeout: 1000,
         cache:false,
         error: function(data){
            eventajaxError(this);
         },
         success: function(data){
             var drops=[];
             $.each( data , function(i,k){
                 var name=k['title'],
                     links=k['link'];
                 var _html=[
                     '<img data-text="['+name+']" alt="['+name+']" title="'+name+'" src="'+ links +'" />'
                 ].join('\n');
                 drops.push(_html);
             });
             $emotionBox.find('.emotion-login').hide();
             $emotionCont.append(drops.join('\n'));
             eventajaxSucceed.call(this);
         }
     })
 };
Exemplo n.º 26
0
                ConfirmBox.confirm(txt, '亲,你确信不要我了吗?', function() {

                    $.ajax({
                        url:"/theme/removeFollow",
                        type : "post",
                        contentType:"application/json; charset=utf-8",
                        dataType: "json",
                        data: JSON.stringify({"themeId": themeId }),
                        success: function(data){
                            switch(data.code){
                                case("100"):
                                    // $this.data("enable","true");
                                    $.smeite.removeFollowThemeCallback(data,$this);
                                    break;
                                case("104"):
                                    //   $this.data("enable","true");
                                    $.smeite.tip.conf.tipClass = "tipmodal tipmodal-error2";
                                    $.smeite.tip.show($this,"参数错误");
                                    break;
                                case("300"):
                                    $.smeite.dialog.login();
                                    break;
                            }
                        }
                    });
                });
Exemplo n.º 27
0
 function radioClickHandler() {
   var feedback = $(this).closest('.feedback');
   var chatlogid = feedback.data('chatlogid');
   var knowtype = feedback.data('knowtype');
   var instanceid = feedback.data('instanceid');
   feedback.html(FEEDBACKSUCC + '<div class="arrow"></div>');
   $.ajax('feedback.jspa', {
     type: 'post',
     dataType: 'html',
     data: {
       sessionUuid: SESSIONUUID,
       cacheChatLogId: chatlogid,
       conversationInstanceId: instanceid,
       knowType: knowtype,
       userId: LOGINID,
       feedback: this.value,
       sourceType: SOURCETYPE
     },
     success: function (data) {
       if (data.trim() === 'true') {
         //success
       }
     }
   });
 }
Exemplo n.º 28
0
        reset: function() {
            if (shelper.check.all()) {
                var oldPassword = $.trim($('#old_password').val());
                var password = $.trim($('#password').val());

                $.ajax({
                    url: '/api/change_password',
                    method: 'put',
                    data: helper.stringify({
                        'old_value': oldPassword,
                        'new_value': password
                    }),
                    success: function (data) {
                        if (+data['meta']['code'] === 200) {
                            Tip.auto('修改密码成功', 'success');
                        } else {
                            Tip.auto(data['meta']['message'], 'error');
                        }
                    },
                    error: function (res) {
                        Tip.auto(res.responseJSON.meta.message, 'error');
                    },
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'Application/json; charset=UTF-8'
                });
            }
        }
Exemplo n.º 29
0
        _getUrlData: function(query) {
            var that = this, options;
            var obj = {
                query: query ? encodeURIComponent(query) : '',
                timestamp: new Date().getTime()
            };
            var url = this.get('source')
                .replace(/{{(.*?)}}/g, function(all, match) {
                    return obj[match];
                });

            var callbackId = 'callback_' + this.id++;
            this.callbacks.push(callbackId);

            if (/^(https?:\/\/)/.test(url)) {
                options = {dataType: 'jsonp'};
            } else {
                options = {dataType: 'json'};
            }
            $.ajax(url, options)
                .success(function(data) {
                    if ($.inArray(callbackId, that.callbacks) > -1) {
                        delete that.callbacks[callbackId];
                        that._done(data);
                    }
                })
                .error(function() {
                    if ($.inArray(callbackId, that.callbacks) > -1) {
                        delete that.callbacks[callbackId];
                        that._done({});
                    }
                });
        },
Exemplo n.º 30
0
 var __SendCode = function (that) {
     var phone = $("#Phone").val();
     if ( !/^0?(13|15|18|17|14)[0-9]{9}$/.test(phone)  ) { return Comm.alertTips({'msg' : '请输入正确的手机号!'}) }
     $.ajax({
         cache: true,
         type: "POST",
         url: gv.URL.SendCode,
         data: {'phone':phone},
         dataType: 'JSON',
         async: false,
         error: function() {
             return Comm.alertTips({'msg' : '发送失败,请稍后再试!!'})
         },
         success: function(data) {
             var status = Number(data.status);
             if ( status==1 ) {
                 Comm.alertTips({'msg': data.message });
                 that.removeClass('btn-orange');
                 __time(that);
             } else {
                 return Comm.alertTips({'msg' : data.message })
             }
         }
     });
 };