如 /app/code/local/Xinson/News/controllers/Adminhtml/NewsController.php 的 editAction() 方法
$this->renderLayout() 之前加
$this->_addContent($this->getLayout()->createBlock('core/text')->setText("
<script>
document.getElementById('placeholder_limit').onblur = function(){
var url = 'http://test.shop.com/serial-codes/';
new Ajax.Request(url, {
method: 'post',
onSuccess: function(text) {
//yourtext = text.responseText.evalJSON(true);
document.getElementById('placeholder_limit').parentNode.innerHTML += '<span><img src=http://test.shop.com/media/wysiwyg/sdk/categories-4.jpg width=20%></span><span><img src=http://test.shop.com/media/wysiwyg/sdk/categories-4.jpg width=20%></span>';
},
onFailure: function() {
return false;
},
onException: function() {
return false;
}
});
return true;
}
</script>
"));
还有另外一种在/app/code/local/Xinson/News/controllers/Adminhtml/News/Edit.php 的 __construct()
最后加
$this->_formScripts[] = "
document.getElementById('placeholder_limit').onblur = function(){
var url = 'http://test.shop.com/serial-codes/';
new Ajax.Request(url, {
method: 'post',
onSuccess: function(text) {
},
onFailure: function() {
return false;
},
onException: function() {
return false;
}
});
return true;
}
";