Jehan Ramadhan
Jehan Ramadhan

Reputation: 65

PhantomJS page.includeJs Not Working

I want to create sample script to login at my website.
My script like this :

var page   = require("webpage").create();
var system = require("system");
var data   = {
    "username": system.args[1],
    "password": system.args[2]
}

function login(data){
    page.open("http://localhost/mywebsite/login.php", function(){
        page.includeJs("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js", function(){
            console.log("Come in here.");
            phantom.exit();
        )}
    )}
}
login(data);

When I run phantomjs in terminal, example : phantomjs myscript.js admin admin
i dont get anything in my terminal.
what's wrong in my code?

Upvotes: 0

Views: 438

Answers (1)

Dinesh undefined
Dinesh undefined

Reputation: 5546

The way you closing callbacks is wrong. you are closing like this )}.it should be });

Your code here

var page   = require("webpage").create();
var system = require("system");
var data   = {
    "username": system.args[1],
    "password": system.args[2]
}

function login(data){
    page.open("http://localhost/mywebsite/login.php", function(){
        page.includeJs("https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js", function(){
            console.log("Come in here.");
            phantom.exit();
        });
    })
}
login(data);

Upvotes: 1

Related Questions