forms – how to implement the Ajax callback on form_alter for the entity field?

I want to display the image of a drop-down menu when a content is changed or created.

Note: I do not create form elements, I use them.

For one type of content, I have a field_select drop-down list (entity reference to another type of content). I'm trying to edit my listing to view images of the selected entity from the drop-down list.

I am new to ajax callback functions and I need a little help here.

I have searched a lot and tried to implement it and I have failed.

function custom_form_alter (& $ form, & $ form_state, $ form_id) {

if ($ form_id == "article_node_form") {
$ form['field_select']['und']['#ajax']    = table (
& # 39; callback & # 39; => & # 39; field_select_ajax_callback & # 39 ;, what does it return?
& # 39; wrapper & # 39; => "Image-sponsor", // where to use it?
)
$ form['field_select']['und']['#prefix']    = & # 39;
& # 39 ;; $ form['field_select']['und']['#suffix'] = & # 39;
& # 39 ;; } function field_select_ajax_callback ($ form, $ form_state) { return form $['field_select']; // where should i return $ form['field_select']['und']['#options']; //? }

exit from my dsm ($ form):

$ form => array (
['field_select'] => table (
  ['und'] => table (
    ['#options'] => table ( 
      [_none] => -None-
        [1] => content1 // 1 is the key
        [2] => content2 // 2 is the key
        [3] => content3 // 3 is the key
)
)
)
)

I want to display a selected drop-down image next to the selected field

I am able to print the image with the help of the following, but I am unable to get the key drop-down item selected to render the node and print it. picture.

Where should this code go?

    $ node_id = node_load ($ key); // issue gets the selected key value of the ajax call.
if (is_object ($ node_id)) {
$ image_uri = $ node_id-> field_image['und'][0]['uri'];
$ image_url = file_create_url ($ image_uri);
$ image = & # 39;& # 39 ;;
print ($ image);
}