QuestionsAdd ajax at magento backend field
mmvikram kumar asked 3 weeks ago

$storeManager = $objectManager->get(‘\Magento\Store\Model\StoreManagerInterface’);

$URLBASE =  $storeManager->getStore()->getBaseUrl();

$URLBASEURLajax = $URLBASE.’admin/uploadfiles_filescollection/items/ajax’;

$fieldset->addField(‘categories’, ‘multiselect’, array(

‘label’ => __(‘Category List’),

‘class’     => ‘required-entry addproductlistalso’,

‘values’ => $collectionCat,

‘name’      => ‘categories’,

‘onclick’ => ‘checkSelectedItem()’

))->setAfterElementHtml(”

<script type=\”text/javascript\”>

require([‘jquery’, ‘jquery/ui’], function($){

$(document).ready(function(){                                                                                                                                                                                                      //alert(‘functicon’);

});

});

 

function checkSelectedItem(){

var select1 = document.getElementById(‘item_categories’);

var selected1 = [];

for (var i = 0; i < select1.length; i++) {

if (select1.options[i].selected) selected1.push(select1.options[i].value);

}

jQuery.ajax( {

url: ‘”.$URLBASEURLajax.”/catid/’ + selected1,

data: {form_key: window.FORM_KEY},

type: ‘POST’

}).done(function(a) {

//console.log(a);

//jsonObject = a.responseText.evalJSON();

document.getElementById(‘item_product_ids’).innerHTML= a;

});

}

</script>”);

Your Answer
Login
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.