简体   繁体   中英

How to fix babel-polyfill error? Can't find in my code

I have a simple page with a button and a textbox, where I input a sql query, that sends data to a php file that returns the query result on the page.

Here are my codes:

   <div class="row larger-font">

   <div class="container">
     <p><strong> Some text goes here </strong></p>
   <div class="row">

   <div class="col-md-6">
            <div id="simpleButton">
                            <button  type="button"   class="btn btn-primary">Execute!</button>
                    </div>
            </div>
            <div class="col-md-6">
                    <div class="form-group">
                            <input type="text" class="form-control" id="sampleInput" name="sql">
                    </div>
            </div>
            <div id="result">  </div>
    </div>
    </div>
    </div>
    </div>
          <script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
          <script>
          $('#simpleButton').click(function(e) {
          var val1 = $('#sampleInput').val();
          $.ajax({
          type: 'POST',
          url: 'mahsql',
          data: { sampleInput: val1 },
          success: function(response) {
          $('#result').html(response);
          }
          });
          });
          </script>

The weird part is, I get my results on the page, no problem; however, I get this pop up error saying only one instance of babel-polyfill is allowed. I cannot understand this. I am not using anything babel. Is there a way to suppress that error from here? I am confused because I can see the result, but I still get this annoying pop up error. Any help is appreciated, thanks.

UPDATE: Here's mahsql.php:

<?php
$conn = oci_connect('username', 'password', 'hostname/db_svc');
if (!$conn) {
    $e = oci_error();
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
$query = $_POST['sampleInput'];
$stid = oci_parse($conn, $query);
oci_execute($stid);

echo "<table border='1'>\n";
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
    echo "<tr>\n";
    foreach ($row as $item) {
        echo "    <td>" . ($item !== null ? htmlentities($item, ENT_QUOTES)     : "&nbsp;") . "</td>\n";
    }
    echo "</tr>\n";
}
echo "</table>\n";
?>

Following the comments, I pushed F12 on chrome looked at the Chrome tab and I see this javascript code under my .php file with the html, that's called newtestingm.php.

This is the extra bit of code that's throwing the error:

<div id="preloader"></div><script type="text/javascript">
var isLoggedIn=false;
var preload=[];
var isAdmin=false;

</script><script type="text/javascript">

</script><script>
    (function(i,s,o,g,r,a,m)    {i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new     Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)    [0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

ga('create', 'UA-53997625-1', 'auto');
ga('send', 'pageview');


</script>
<script src="http://servername:1338/webpack-dev-server.js"></script><script    crossorigin="anonymous" src="http://servername:1338/all.8a98aeb6b75576ce1df6.js">    </script><script crossorigin="anonymous"     src="http://servername:1338/newtestingm.8a98aeb6b75576ce1df6.js"></script></body>    </html>

What is this??? It's not part of my php file.

The resource at mahsql is returning html with an embedded script tag. You are unconditionally injecting this html into your page and executing it. This is extremely unwise.

As you have not included all of your html it is difficult to determine the exact cause of the error. Basically, a script which is only intended to be executed a single time is being executed multiple times.

Based on the updates and comments it appears that your server is appending markup containing google analytics, a script requesting Webpack's development server, and also setting some global variables. Webpack is likely what is requesting Babel.

My advice is to take a step back and examine all of the tools you are using as this should not be happening without your knowledge. Perhaps you are using a combination of server and client side frameworks, starter kits, and templates that are generating code you are unaware of. The results of this are hard to predict and reason about without having an in depth knowledge of your full stack.

I don't have good knowledge of the frameworks you are using, and I rarely write PHP, but the general problem is that you are not aware of the breadth of code being executed. There is clearly a fairly complex stack in play that is making assumptions. For example it seems to be assuming that you have a Webpack bundle with a name corresponding to your html page being served from the same location. If that is not the case you will receive errors. But it is just one example of a large number of assumptions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM