- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在 virtuemart Joomla 1.5 中的 rockettheme 的 vm mynxx 模板中使用下面的脚本时出现错误 -
它在 mynxx 之外工作正常
用户将数据输入 html 表单 - 按下“获取价格”按钮,价格将返回到相同的表单。问题是用户无法提交到购物车
Firebug 错误-
callback is not a function callback(this.responseText);
我的 ajax 脚本
function Ajax() {
this.instance = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
this.request = function(url, callback) {
this.instance.open('GET', url, true);
this.instance.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
callback(this.responseText);
}
}
this.instance.send(null);
}
}
function validate(form) {
(new Ajax).request('testform.php?width65=' + form.width65.value + '&length65=' + form.length65.value, function(respons) {
var prices = eval(respons);
form.price.value = prices[0];
form.otherprice.value = prices[1];
});
}
我想我已经追踪到 theme.js 文件并需要一些代码来验证该功能。
我是新手,这远远超过我 - 任何帮助将不胜感激
Theme.js 代码 - 已打包 - 即 eval(function(p,a,c,k,e,r){e=function(c)...... 我已经解包了
var RokVM = {};
RokVM.autoHide = 3; // seconds before auto closing the Panel
RokVM.Base=
{
uri:window.templatePath,start:function()
{
RokVM.Base.quantityBox();
RokVM.Cart.init()
}
,featuredHeight:function(b)
{
b=$(b);
if(!b)
{
return RokVM.Base
}
var c=b.getElements(".home-featured-inner");
var d=0;
c.each(function(a)
{
d=Math.max(a.getSize().size.y,d)
}
);
c.setStyle("height",d)
}
,quantityBox:function()
{
var h=$$(".cart-quantity-box, .home-featured-cartblock");
if(h.length)
{
h.each(function(b)
{
var c=b.getElement(".quantity_box_button_up");
var d=b.getElement(".quantity_box_button_down");
var f=b.getElement(".inputboxquantity");
if(!c||!d||!f)
{
return
}
var g=f.getValue().toInt();
f.addEvent("keyup",function(e)
{
e=(new Event(e)).stop();
var a=this.value;
if(a<0)
{
a=0
}
if(isNaN(a))
{
this.value=1;
a=1
}
if(e.key=="up")
{
if($type(this.getValue().toInt())=="number")
{
this.value=++a
}
}
if(e.key=="down")
{
if(a>0&&$type(this.getValue().toInt())=="number")
{
this.value=--a
}
}
}
);
f.addEvent("mousewheel",function(e)
{
e=(new Event(e)).stop();
var a=this.value;
if(a<0)
{
a=0
}
if(isNaN(a))
{
this.value=1;
a=1
}
if(e.wheel==1)
{
if($type(this.getValue().toInt())=="number")
{
this.value=++a
}
}
if(e.wheel==-1)
{
if(a>0&&$type(this.getValue().toInt())=="number")
{
this.value=--a
}
}
}
);
c.addEvent("click",function(e)
{
(new Event(e)).stop();
if($type(f.getValue().toInt())=="number")
{
f.value=++f.value
}
}
);
d.addEvent("click",function(e)
{
(new Event(e)).stop();
if(f.getValue().toInt()>0&&$type(f.getValue().toInt())=="number")
{
f.value=--f.value
}
}
)
}
)
}
}
};
RokVM.Cart=
{
init:function()
{
RokVM.Cart.cartPanel=$("cart-panel");
RokVM.Cart.cartButton=$("cart-button");
RokVM.Cart.cartSurround=$("cart-panel-surround");
if(!RokVM.Cart.cartPanel||!RokVM.Cart.cartButton||!RokVM.Cart.cartSurround)
{
return RokVM.Cart
}
if(!RokVM.Cart.Fx)
{
RokVM.Cart.Fx=(new(Fx.Slide)(RokVM.Cart.cartPanel,
{
duration:400,transition:Fx.Transitions.Expo.easeOut
}
)).hide()
}
RokVM.Cart.cartSurround.setStyle("visibility","visible");
RokVM.Cart.cartButton.getFirst("a").addEvent("click",function(e)
{
(new Event(e)).stop();
if(!RokVM.Cart.cartPanel.getText().length&&!window.webkit)
{
return
}
if(!RokVM.Cart.cartPanel.innerHTML.clean().length&&window.webkit)
{
return
}
var a=RokVM.Cart.cartButton.getElement("strong");
if(!a||!a.getText().toInt()&&(!RokVM.Cart.cartPanel.getText().length&&!window.webkit))
{
return
}
RokVM.Cart.clicked=true;
if(window.fontFx&&window.fontFx.open)
{
window.fontFx.toggle()
}
if(window.loginFx&&window.loginFx.open)
{
window.loginFx.toggle()
}
RokVM.Cart.Fx.toggle()
}
);
RokVM.scrollWindow=new(Fx.Scroll)(window);
RokVM.Cart.getShortList();
RokVM.Cart.XHRify()
}
,XHRify:function()
{
var b=$$(".addtocart_form");
if(!b.length)
{
return RokVM.Cart
}
b.each(function(a)
{
a.addEvent("submit",RokVM.Cart.add.bindWithEvent(a,true))
}
)
}
,add:function(e,c)
{
(new Event(e)).stop();
(new Ajax(this.getProperty("action"),
{
data:$(this),evalScripts:true,onComplete:function(r)
{
var a=new Element('div').setHTML(r);
var b=a.getElement('.shop_tip');
RokVM.Cart.getShortList((r.length&&b)?r:false);
RokVM.Cart.clicked=c||false
}
}
)).request()
}
,getShortList:function(b)
{
var c=
{
onComplete:function(a)
{
RokVM.Cart.update(a,b)
}
,evalScripts:true,data:
{
only_page:1,page:"shop.basket_short",option:"com_virtuemart"
}
};
(new Ajax(RokVM.Base.uri+"index2.php",c)).request()
}
,handleError:function(a)
{
var b=RokVM.Cart.cartPanel;
var c=new Element('div').setHTML(a);
var d=b.getElement('.show-cart-button');
var e=c.getElement('.shop_tip').inject((d)?d:b,(d)?'before':'inside')
}
,update:function(a,b)
{
RokVM.Cart.cartPanel.setHTML(a);
var c=RokVM.Cart.cartPanel.getElement(".total_products"),total=0;
if(c)
{
total=c.innerHTML.split(" ")[0].toInt()
}
if(!total)
{
RokVM.Cart.cartButton.getFirst().setProperty("class","cart-button-desc")
}
else
{
RokVM.Cart.cartButton.getFirst().setProperty("class","cart-button-desc-full")
}
RokVM.Cart.cartButton.getElement("strong").setText(total);
if(b)RokVM.Cart.handleError(b);
if(RokVM.Cart.clicked&&a.length||b)
{
if(window.fontFx&&window.fontFx.open)
{
window.fontFx.toggle()
}
if(window.loginFx&&window.loginFx.open)
{
window.loginFx.toggle()
}
RokVM.scrollWindow.toTop();
RokVM.Cart.show();
RokVM.Cart.hide.delay(RokVM.autoHide*1000)
}
RokVM.Cart.clicked=false
}
,show:function()
{
RokVM.Cart.Fx.slideIn()
}
,hide:function()
{
RokVM.Cart.Fx.slideOut()
}
};
window.addEvent("domready",RokVM.Base.start);
window.addEvent(window.webkit?"load":"domready",function()
{
RokVM.Base.featuredHeight("home-featured")
}
);
var live_site = RokVM.Base.url;
然后是 - 在同一个 theme.js 文件中(未打包)
/// Following is VM stuff, kept for compatibility
/**
* This file holds javascript functions that are used by the templates in the Theme
*
*/
// AJAX FUNCTIONS
function loadNewPage( el, url ) {
var theEl = $(el);
var callback = {
success : function(responseText) {
theEl.innerHTML = responseText;
if( Lightbox ) Lightbox.init();
}
}
var opt = {
// Use POST
method: 'get',
// Handle successful response
onComplete: callback.success
}
new Ajax( url + '&only_page=1', opt ).request();
}
function handleGoToCart() { document.location = live_site + '/index.php?option=com_virtuemart&page=shop.cart&product_id=' + formCartAdd.product_id.value ; }
function handleAddToCart( formId, parameters ) {
formCartAdd = document.getElementById( formId );
var callback = function(responseText) {
updateMiniCarts();
// close an existing mooPrompt box first, before attempting to create a new one (thanks wellsie!)
/*if (document.boxB) {
document.boxB.close();
clearTimeout(timeoutID);
}
document.boxB = new MooPrompt(notice_lbl, responseText, {
buttons: 2,
width:400,
height:150,
overlay: false,
button1: ok_lbl,
button2: cart_title,
onButton2: handleGoToCart
});
setTimeout( 'document.boxB.close()', 3000 );*/
}
var opt = {
// Use POST
method: 'post',
// Send this lovely data
data: $(formId),
// Handle successful response
onComplete: callback,
evalScripts: true
}
new Ajax(formCartAdd.action, opt).request();
}
/**
* This function searches for all elements with the class name "vmCartModule" and
* updates them with the contents of the page "shop.basket_short" after a cart modification event
*/
function updateMiniCarts() {
var callbackCart = function(responseText) {
carts = $$( '.vmCartModule' );
if( carts ) {
try {
for (var i=0; i<carts.length; i++){
carts[i].innerHTML = responseText;
try {
color = carts[i].getStyle( 'color' );
bgcolor = carts[i].getStyle( 'background-color' );
if( bgcolor == 'transparent' ) {
// If the current element has no background color, it is transparent.
// We can't make a highlight without knowing about the real background color,
// so let's loop up to the next parent that has a BG Color
parent = carts[i].getParent();
while( parent && bgcolor == 'transparent' ) {
bgcolor = parent.getStyle( 'background-color' );
parent = parent.getParent();
}
}
var fxc = new Fx.Style(carts[i], 'color', {duration: 1000});
var fxbgc = new Fx.Style(carts[i], 'background-color', {duration: 1000});
fxc.start( '#222', color );
fxbgc.start( '#fff68f', bgcolor );
if( parent ) {
setTimeout( "carts[" + i + "].setStyle( 'background-color', 'transparent' )", 1000 );
}
} catch(e) {}
}
} catch(e) {}
}
}
var option = { method: 'post', onComplete: callbackCart, data: { only_page:1,page: "shop.basket_short", option: "com_virtuemart" } }
new Ajax( live_site + '/index2.php', option).request();
}
/**
* This function allows you to present contents of a URL in a really nice stylish dhtml Window
* It uses the WindowJS, so make sure you have called
* vmCommonHTML::loadWindowsJS();
* before
*/
function fancyPop( url, parameters ) {
parameters = parameters || {};
popTitle = parameters.title || '';
popWidth = parameters.width || 700;
popHeight = parameters.height || 600;
popModal = parameters.modal || false;
window_id = new Window('window_id', {className: "mac_os_x",
title: popTitle,
showEffect: Element.show,
hideEffect: Element.hide,
width: popWidth, height: popHeight});
window_id.setAjaxContent( url, {evalScripts:true}, true, popModal );
window_id.setCookie('window_size');
window_id.setDestroyOnClose();
}
最佳答案
我真的不知道这个模板,但我认为 function callback() 是应该在它的代码中指定的东西,以便在服务器 (HTTP 200) 有肯定响应时使用react,那么你也可以给我们:
关于javascript - 在 virutemart/Joomla 中通过 rockettheme 在 vm mynxx 模板中使用 AJAX 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6373561/
已关闭。这个问题是 off-topic 。目前不接受答案。 想要改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 已关闭11 年前。 Improve th
我是 Azure 平台的初学者。我在公司的 Azure 基础架构中遇到了虚拟机问题,在我从操作系统重新启动后,该虚拟机无法启动,我尝试了所有其他故障排除功能,但仍遇到以下问题: 重新部署选项。 我想确
我在 Mac 上使用 XAMPP-VM,我尝试使用 xampp 管理器上显示的地址通过 ssh 连接到 VM: 192.168.65.2 我意识到我不知道 VM 的 root 密码和任何 ssh-ke
我知道你可以在 Dalvik 的 VM 中运行几乎所有的 Java,而你可以在 Java 的 VM 中运行,但是限制不是很清楚。有没有人遇到任何主要的绊脚石?有什么大图书馆有问题吗?任何编译成 Jav
Azure VM 备份失败,出现错误 - GuestAgentSnapshotTaskStatusErrorAzure 备份服务无法与 VM 代理通信以触发快照(以进行备份),因为 VM 代理可能处于
我想知道当虚拟机停止时,虚拟机的软件成本部分是否收费。我想运行 Azure SQL VM Enterprise。 VM 每月的软件成本为“1,116 美元/月”。 如果我停止使用,我仍需支付该软件的费
有 2 台安装了 Proxmox (Proxmox-ve 4.2) 的物理服务器,每台都处理几个虚拟机和容器。这些服务器(几乎)完全隔离,它们之间没有集群/共享存储/附加存储等。 已在 proxmox
我想知道当虚拟机停止时,虚拟机的软件成本部分是否收费。我想运行 Azure SQL VM Enterprise。 VM 每月的软件成本为“1,116 美元/月”。 如果我停止使用,我仍需支付该软件的费
有 2 台安装了 Proxmox (Proxmox-ve 4.2) 的物理服务器,每台都处理几个虚拟机和容器。这些服务器(几乎)完全隔离,它们之间没有集群/共享存储/附加存储等。 已在 proxmox
Parrot Virtual Machine 有什么好处?对于最终用户(软件开发人员)? 例如,如果我可以直接针对 Perl 或 Python 进行编程,我为什么还要在 Parrot 下为它们编程呢?
例如,Python 和 Java 有一个 VM,而 C 和 Haskell 没有。 (如果我错了,请纠正我) 想了想线路两边都有哪些语言,找不到原因。 Java 在很多方面都是静态的,而 Haskel
我知道虚拟机镜像有两种类型:通用型和专用型。 如果操作系统已通用化/取消配置,则必须关闭虚拟机才能将其捕获为 VM 镜像。一旦 VM 被捕获为 VM 镜像,该虚拟机将自动删除。 如果操作系统是专用,则
我知道虚拟机镜像有两种类型:通用型和专用型。 如果操作系统已通用化/取消配置,则必须关闭虚拟机才能将其捕获为 VM 镜像。一旦 VM 被捕获为 VM 镜像,该虚拟机将自动删除。 如果操作系统是专用,则
背景信息 我正在开发一种支持网络的嵌入式设备,旨在与服务器进行通信。因为此服务器将运行 Linux(但我需要 Windows 工具进行开发),我正在运行带有 Ubuntu Server 14.04 的
我有一个 Azure 云服务 mywebapp.cloudapp.net,它由两个 Azure VM - mywebappvm1 和 mywebappvm2 组成。两个虚拟机位于同一可用性集中并具有相
有什么方法可以在不重新启动虚拟机的情况下调整现有虚拟机的大小,还是总是像停止虚拟机然后重新启动一样? 据我了解,我可以更改虚拟机的大小而无需重新启动它。请指导我,因为我不希望虚拟机在调整大小时出现任何
我是 Azure 新手。我正在尝试使用 powershell 在 Azure 中创建资源。 我的要求是从虚拟机创建镜像。我遵循了以下方法: 流程 1:手动执行 通用化虚拟机:登录虚拟机 -> 打开命令
我创建了虚拟网络,并且想要将新虚拟机部署到该虚拟网络。网络 我尝试使用以下命令创建虚拟机: az vm create --resource-group myGroup --name VMTestNet
上下文 作为一个大学项目,我们希望更改 pharo 虚拟机以使用对象表,看看会发生什么。 我们使用pharo-vm clone from github和VMMaker。构建虚拟机工作正常。 首先,我们
我是巴拿马型的新手,刚刚安装,但收到以下错误消息: A different VM with name panamax-vm has been created already. 我试图通过使用 pana
我是一名优秀的程序员,十分优秀!