user5702166
user5702166

Reputation:

Proper syntax for injecting a Javascript function

So I am trying to use PhantomJS to create a program that checks the inventory of (x) number of stores and (x) number of SKUs. I have had some trouble, though I found this deep in the javascript cookie code:

javascript:storeAvailabilyAjaxSubmitWrapper('11220 Rojas Drive Suite C7, El Paso, TX 79935','/​web/​AjaxStoreAvailabilityDisplay?​langId=-1&​storeId=10151&​catalogId=10051&​partNumber=5792304&​productId=-49951656&​partType=&​category=&​quantity=1&​appId=&​showPricing=true&​address=11220+Rojas+Drive+Suite+C7%2c+El+Paso%2c+TX++79935')​;​

To give a bit more background, the website is based so that you choose a "favorite store" and it checks using this javascript. This seems to be a function that checks through database (I could be totally off on this), so I want to know the syntax to allow it to be injected. Thanks!

Upvotes: 0

Views: 37

Answers (1)

Leroy Thompson
Leroy Thompson

Reputation: 480

//USE JQUERY

$.getScript("syntax.js")
                    .done(function (script, textStatus) {
                        console.log(textStatus);
                        $("#err").html("Good Code");
                        success = true;
                    })
                    .fail(function (jqxhr, settings, exception) {
                        $("#err").html("Bad Code");
                        success = false;
                    });

////OR LOCAL FOLDER

localFolder.getFileAsync("syntax.js")
                    .then(function (checkFile) {
                        return Windows.Storage.FileIO.readTextAsync(checkFile);
                    }).done(function (fileData) {
                        $("#err").html("Good Code");
                        success = true;
                    }, function () {
                        $("#err").html("Bad Code");
                        success = false;
                    });

///Use EVAL

try {
    eval(code); 
} catch (e) {
    if (e instanceof SyntaxError) {
        alert(e.message);
    }
}

Upvotes: 1

Related Questions