简体   繁体   English

magento:下拉列表更改时自定义ajax调用

[英]magento :custom ajax call on dropdown change

i added custom.js to my product edit page 我向我的产品编辑页面添加了custom.js

i have added attribute with id "getdata" now there is another file where value show based on what user select in dropdown 我添加了ID为“ getdata”的属性,现在还有另一个文件,其中根据用户在下拉菜单中的选择显示值

i need to do ajax call to other page with value of dropddown , calling ajax is simple i want to use magento built in way of calling ajax url and loader also how can i do it ?? 我需要使用dropddown的值对其他页面进行ajax调用,调用ajax很简单,我想使用以调用ajax url和loader的方式构建的magento,我该怎么做?

i wrote below code but its now working 我写了下面的代码,但现在可以工作了

function myajaxcall(id){
new Ajax.Request('/a.php?id='+id, {
  onSuccess: function(response) {
    alert(response);
  }
});
}

what am i missing pls help 我缺少什么帮助

Try to use the below code : 尝试使用以下代码:

    function myajaxcall(id){

new Ajax.Request('a.php?id='+id, {
  method:'get',
  onSuccess: function(data) {
    var response = data.responseText || "no response text";
    alert("Success! \n\n" + response);
  },
  onFailure: function() { alert('Something went wrong...'); }
});
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM