Button in form not working properly I am unable to get a button to work as I intend it to in Drupal 7.

I am adding the button to the add content page of a specific content type using form alter:

function charlie_get_form_article_link_node_form_alter(&amp;$form, &amp;$form_state, $form_id) {

    $form['add_button'] = array(

        '#type' =&gt; 'item',

        '#markup' =&gt; '  
            &lt;script&gt;
                function getArticleInfo() {
                    jQuery.get("articlegrabber.php?url=TEST", function(articleHTML) {
                        console.log(articleHTML);
                    });
                    return false;                       
                }
            &lt;/script&gt;

            &lt;button type="button" onclick="getArticleInfo()"&gt;
                Submit URL
            &lt;/button&gt;

        ',

    );

}


I have simplified the articlegrabber.php file down to just this (though I don't think it matters, because the button click does not seem to be executing the JS):

&lt;?php

$ogLink = $_GET['url'];

echo $ogLink;  ?&gt;


Instead of my intended results (which the code delivers independent of its implementation in Drupal), the console logs the HTML for the add content page that the button is on.

I have read a lot about how Drupal likes to make all button types "submit", but my button is actually rendering as type="button". The HTML from the rendered page (as you would expect):

                    &lt;script&gt;
                        function getArticleInfo() {
                            jQuery.get("articlegrabber.php?url=TEST", function(articleHTML) {
                                console.log(articleHTML);
                            });
                            return false;                       
                        }
                    &lt;/script&gt;

                    &lt;button type="button" onclick="getArticleInfo()"&gt;
                        Submit URL
                    &lt;/button&gt;


Any ideas about how to get it to execute the code on click rather than returning the HTML for the page would be much appreciated.
You need Simple Drupal AJAX load with jQuery and delivery callback  which is explained in  5 simple steps this page.

So include a anchor link through the form alter and have the link render the content through attached javascript file through jQuery.load() function.

To attach js file, 

$form['#attached']['js'][] = array(
  'data' =&gt; drupal_get_path('module', 'module_name') . '/some_file.js',
  'type' =&gt; 'file', 
);


For Drupal ajax forms refer this official documentation.