How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site. Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask ATLPROG Your Own Question
ATLPROG
ATLPROG, Computer Software Engineer
Category: Programming
Satisfied Customers: 7260
Experience:  MS in IT.Several years of programming experience in Java C++ C C# Python VB Javascript HTML
44910485
Type Your Programming Question Here...
ATLPROG is online now

How do I integrate the following javascript into a single html

Customer Question

How do I integrate the following javascript into a single html webpage?

// This module requires jQuery.

try {
// Enable module to work with jQuery in Node.JS
var $ = require('jquery').create();
}
catch(e) {}

var medacs = {};


medacs.Getting = function (callback) {
var type = 'GET';

var headers = {
"Accept-Language": "en-US,en;q=0.8",
"X-Requested-With": "XMLHttpRequest",
"Host": "www.medacs.com",
"Referer": "http://www.medacs.com/locum-doctor-jobs",
"Accept-Encoding": "gzip,deflate,sdch",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36",
"Connection": "keep-alive",
"Accept": "*/*",
};

var queryString = "?" + "" + "=" + encodeURIComponent("") + "&" + "skill[]" + "=" + encodeURIComponent("Accident+&+Emergency") + "&";

var data = "";

var url = "http://www.medacs.com/locum-doctor-jobs" + queryString;

$.ajax({
type: type,
url: url,
headers: headers,
data: data,
beforeSend: function(xmlHttpRequest) {
// Requires node-XMLHttpRequest version 1.5.1 or later to set some headers in Node.js
if(xmlHttpRequest.setDisableHeaderCheck) xmlHttpRequest.setDisableHeaderCheck(true);
return true;
}
})
.always(
function (response, error) {
response = response || '';

if (!response.responseText) {
try {
var $html = $(toStaticHTML(response));
}
catch(e) {
var $html = $(response);
}
}
else response = response.responseText;
var _selector = $html.find('a.job-name');

var fullResponse = {
response: response,
selector: _selector,
};

callback(null, fullResponse);

}
);
};
if(typeof(exports) != "undefined") exports.Getting = medacs.Getting; // For nodeJS
Submitted: 3 years ago.
Category: Programming
Expert:  Martin replied 3 years ago.
Hello, welcome to JustAnswer my name is Martin and I'm one of the experts who will be assisting you today.

You need to put that code into a file with a .js extension, for example myscript.js

Then from your HTML page, you need to call it with the following code:

http://codepad.org/KNR2ltFS

As you can see it is called within the header tags.

Is this what you're inquiring about?

Regards,
Martin