<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python not running on ajax script in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360931#M39942</link>
    <description>&lt;P&gt;i just put the python script in the local server&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 08:04:17 GMT</pubDate>
    <dc:creator>japposadas</dc:creator>
    <dc:date>2018-02-08T08:04:17Z</dc:date>
    <item>
      <title>Python not running on ajax script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360929#M39940</link>
      <description>&lt;P&gt;Hi Guys, i'm trying to run an ajax script with a url to a python script. Everytime  i tried to run it it seems that it has no error, but it's not working and the script do not continue to the click function. When I tried removing the type: POST in ajax, i got an error which is &lt;STRONG&gt;&lt;EM&gt;POST &lt;A href="http://localhost:8001/en-US/app/Splunk_ML_Churn/trial2.js" target="_blank"&gt;http://localhost:8001/en-US/app/Splunk_ML_Churn/trial2.js&lt;/A&gt; 404 (Not Found)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;here is my sample code&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;require([ &lt;BR /&gt;
  "jquery",&lt;BR /&gt;
  'splunkjs/mvc', &lt;BR /&gt;
  "splunkjs/mvc/simplexml/ready!"],&lt;BR /&gt;
          function($,mvc){&lt;BR /&gt;
            var tokens = mvc.Components.get("default");&lt;BR /&gt;
                $("#equation_btn_Run").on("click", function (){&lt;BR /&gt;
                    console.log("BTN_RUN") &lt;BR /&gt;
                        $.ajax({&lt;BR /&gt;
                            type: "POST",&lt;BR /&gt;
                            url: "trial1.py",&lt;BR /&gt;
                            success: function(response) {&lt;BR /&gt;
                               console.log("hello");&lt;BR /&gt;
                            }&lt;BR /&gt;
                        });&lt;BR /&gt;
                });&lt;BR /&gt;
                $('#equation_btn_Save').on("click", function (){ // When button click&lt;BR /&gt;
                  console.log("BTN_SAVE") &lt;BR /&gt;
                 });&lt;BR /&gt;
                  $('#macros_table').on("click", function (){ // When button click&lt;BR /&gt;
                    var Equation_name_tok = tokens.get("Equation_name_tok").substr(1).slice(0, -1);&lt;BR /&gt;
                     var Equation_value_tok = tokens.get("Equation_value_tok");&lt;BR /&gt;
                     $('#Equation_Name').val(Equation_name_tok);&lt;BR /&gt;
                     $('#Equation_Value').val(Equation_value_tok);&lt;BR /&gt;
                   });&lt;BR /&gt;
              });&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;please give me some ideas, thanks in advance! Happy Splunking&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:58:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360929#M39940</guid>
      <dc:creator>japposadas</dc:creator>
      <dc:date>2020-09-29T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Python not running on ajax script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360930#M39941</link>
      <description>&lt;P&gt;How are you hosting the python script that it can receive POST requests?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 01:58:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360930#M39941</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-02-08T01:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python not running on ajax script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360931#M39942</link>
      <description>&lt;P&gt;i just put the python script in the local server&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 08:04:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360931#M39942</guid>
      <dc:creator>japposadas</dc:creator>
      <dc:date>2018-02-08T08:04:17Z</dc:date>
    </item>
    <item>
      <title>Re: Python not running on ajax script</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360932#M39943</link>
      <description>&lt;P&gt;POST is an HTTP action.  The code you write, in javascript, will run in the user's browser and attempt to make an HTTP call based on what you've asked it to POST to.&lt;/P&gt;

&lt;P&gt;Placing a python script on the server is unlikely to allow it to receive HTTP events.&lt;/P&gt;

&lt;P&gt;I think you'll need to take a step back and work to gain an understanding of not only what it is you're looking to accomplish overall, but how the individual components may be used successfully to gain that functionality.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 14:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/Python-not-running-on-ajax-script/m-p/360932#M39943</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-02-08T14:57:44Z</dc:date>
    </item>
  </channel>
</rss>

