Skip to content
Advertisement

Disable AJAX/Javascript popup after AJAX invokes PHP function

Ok so im using AJAX to invoke a php function everything works perfectly except that when the function is completed an empty popup window appears at the top of my page saying “xyz.com says” with an empty box and ok button. I just want it to complete with no popup and append one string to a <P> tag.

ScreenShot

Here is my Javascript:

function buildFunction() {
            document.getElementById("package").innerHTML = "Initializing Powershell...</br>";
            document.getElementById("package").innerHTML += "Building...<br><br>";

            $.ajax({
                    type: 'POST',
                    url: 'build.php',
                    success: function(data) {
                        document.getElementById("package").innerHTML += "Build Complete!";

                    }
                });
        }

build.php

function buildPackage()
{
    $serverName = "\\server";
    $msiName = '"""""""""MSI"""""""""';
    $installDir = '"""""""""D:\APP"""""""""';

    $runCMD2 = "start powershell.exe psexec -accepteula -windowstyle hidden -s -i 2 " . $serverName . " cmd /c D:app.hta " . $msiName . " " . $installDir;

    $execCMD = shell_exec("$runCMD2");
    //Begin Building
    echo $execCMD;
}

echo buildPackage();

Advertisement

Answer

So what I ended up doing/figuring out was that the echo statements in my php were creating the pop up! Changing echo => return stopped the pop up.

function buildPackage()
{
    $serverName = "\\server";
    $msiName = '"""""""""MSI"""""""""';
    $installDir = '"""""""""D:\APP"""""""""';

    $runCMD2 = "start powershell.exe psexec -accepteula -windowstyle hidden -s -i 2 " . $serverName . " cmd /c D:app.hta " . $msiName . " " . $installDir;

    $execCMD = shell_exec("$runCMD2");
    //Begin Building
    return $execCMD;
}

return buildPackage();
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement