小编Syl*_*ayé的帖子

如何在magento的默认adminhtml form.php上使用ajax?

$event = $fieldset->addField('parent_id', 'select', array(
    'label' => Mage::helper('gallery')->__('Parent'),
    'required' => true,
    'name'=>'parent_id',
    'values'=>$ac,
    'onchange'=>'CheckSelectedItem()',
  )); 
  $event->setAfterElementHtml('<script>
       function CheckSelectedItem()
       {
       var ddllist= window.document.getElementById("parent_id");
       var itemName= ddllist.options[ddllist.selectedIndex].value;
Run Code Online (Sandbox Code Playgroud)

如何在form.php上为驻留在名为"gallerydata.php"的根文件夹中的文件进行ajax调用.我有一个名为"gallery"的扩展程序,用于从后端上传图像.所以我想通过使用ajax从下拉列表中获取一个艺术家的ID,这会调用该文件"gallerydata.php".

       if(window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
          xmlhttp=new XMLHttpRequest();
          xmlhttp1=new XMLHttpRequest();
          }
        else
          {// code for IE6, IE5
          xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
          }
        xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
            {

             alert(xmlhttp.responseText);

            }
          }

        xmlhttp.open("GET","http://122.170.97.189:81/electriccityusa/gallerydata.php?q="+itemName,true);

       }

    </script>');     
Run Code Online (Sandbox Code Playgroud)

ajax call magento adminhtml

4
推荐指数
1
解决办法
5747
查看次数

标签 统计

adminhtml ×1

ajax ×1

call ×1

magento ×1