[SOLVED] Not getting AJAX to work with GET-call to PHP


#1

Hello, I am not getting AJAX to work. I use this script-structure within my playcanvas-JS:

  • converted to:
autoGenTextSquares.prototype.doautoGenTextSquares = function (screenPosition) {

    var from = this.cameraEntity.getPosition ();

    var to = this.cameraEntity.camera.screenToWorld(screenPosition.x, screenPosition.y, this.cameraEntity.camera.farClip);


    var result = this.app.systems.rigidbody.raycastFirst(from, to);

    if (result) {
        var hitEntity = result.entity; this.firstPosition =hitEntity.getLocalPosition();
        if (hitEntity.name === 'Start_RecDial1'){  
                                          $.ajax({
      type: "GET",
      url: " ... (meta-cloaked) ... /insertChk.php"
    }).done(function( data) {
                                              console.log("req done");
      alert( "Request is done" );
    }); 
                                            }         
});

And within my exported index.html I write the AJAX reference:

.....
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>

    <script src="__start__.js"></script>
    <script src="__loading__.js"></script>
		
</body>
</html>

The page reacts with console and alert, but it doesn’t write to my DB (insertChk.php that already works seprately)

NB: This post is also written within Call external HTML page … ,… states my urgency.


#2

Have you checked the data that you get back from the AJAX request? Is it correct?


#3

Had actually overseen a fault in MySQL-structure (insert failed due to duplex without A_I). Would not have noticed if it weren’t for you answer (I guess). Fixed that, but also changed/tried with POST instead of GET.

Works with both GET and POST now. Thanks.