0

I have a script thats using papa parse to check for an entry in a CSV file, then redirecting based on if its there or not. It works perfectly fine in chrome on my desktop, has a few issues on firefox on my desktop, and completly doesnt work on my chrome browser on my android.

    <body>

<form id="usrform">
    <td><label>Unique ID</label></td>
    <tr>
        <td colspan="2"><input class="textBox" id="uniqueID" type="text" maxlength="30" required/></td>

    </tr>
</form>
    <button onclick="processClick()">Proceed</button>


</body>
<!-- Jquery import -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<!-- Papa Parse CSV -->
<script src="http://localhost/client/js/papaparse.min.js"></script>



<div id="loading" style="background:url(/images/loading.gif) no-repeat center center;width:20px;height:20px; visibility:hidden">
<img src="/images/loading.gif">
</div>

<script>

// hide loading icon
document.getElementById("loading").style.visibility = "hidden";

function processClick()
{
    document.getElementById("loading").style.visibility = "visible";
    if (document.getElementById("uniqueID").value == '' )
    {
        alert("Please fill in the uniqueID field");
        document.getElementById("loading").style.visibility = "hidden";
    }
    else
    {
        parseData(**client site**/csv/csv.csv", searchArray);
    }
}

function parseData(url, callBack) {
    Papa.parse(url, {
        download: true,
        dynamicTyping: true,
        complete: function(results) {
            alert("parsed ready to callback");
            //callBack(results.data);
        }
    });
}

function searchArray(data) {
    //Data is usable here
console.log(" searching array");
    for (a = 0; a < data.length; a++)
{
    if (data[a][1] == document.getElementById('uniqueID').value)
    {
        // redirect
        var target = "**clientsite**" + document.getElementById('uniqueID').value + ".html";
        window.location.assign(target);
        break;
    }
    else
    {
    console.log(" redirecting on fail");
        // redirect to failure page
    }

}
}
</script>

I used alerts to see where it stopped working on mobile, and it appears that the function parseData(url, callBack) { is not returning a value(whether its processing or not i cannot tell).

This works perfectly on chrome/desktop, which is the confusing part!

I imagine im missing something stupid here.

Marak Daga
  • 51
  • 6

1 Answers1

0

There was my error i didnt catch when uploading from testing on my local server. It was working as it could see my localhost file, but it wouldnt for anyone else!

Marak Daga
  • 51
  • 6