Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking Ajax Request From PageMod ContentScriptFile
    primarykey
    data
    text
    <p>I am building this in beta builder and I am really lost as to how to get an ajax call to happen inside my contentScriptFile. I want to pull an ajax request to dynamically pull databack into script so I can alter page contents. I've been searching and searching and apparently for the wrong terms. Help is appreciated! Thanks</p> <p>main.js</p> <p>Code:</p> <pre><code>exports.main = function() {}; var data = require("self").data; var pageMod = require("page-mod"); pageMod.PageMod({ include: "http://www.mozilla.org/*", contentScriptWhen: 'ready', contentScriptFile: [ data.url('jquery.1.7.1.js'), data.url('common.js'), data.url("mozilla.top.js") ] }) </code></pre> <p>mozilla.top.js</p> <p>Code:</p> <pre><code>var qs = parseQS(); var foo= qs['string']; var Request = require('request').Request; Request({ url: "http://www.myremotepage.org?q="+foo, onComplete: function (response) { alert(response); } }).get(); alert('test'); </code></pre> <p>old code to shed light on end goal - http request returns nothing, even though it works in browser. Assumed it was permissions issue with 3rd party ajax tools and started above using add-on request tool.</p> <p>Code:</p> <pre><code>/* $.ajax({ url: 'http://www.myremotepage.org?q='+foo, data: {q:strSearchQuery}, dataType: 'json', success: function(data) { var div = $("&lt;div style='background-color: #ececec;'&gt;&lt;h2 style='text-align: right; font-size: 11px; color: #666;'&gt;Test&lt;/h2&gt;&lt;ul id='ptcid'&gt;&lt;/ul&gt;&lt;/div&gt;"); alert(data.length); for(var i = 0; i &lt; data.length; ++i) { alert('test'); div.find('ul').append('&lt;li&gt;&lt;/li&gt;'); div.find('ul li:last').append('&lt;h3&gt;' + data[i].header+ '&lt;/h3&gt;'); div.find('ul li:last').append('&lt;div&gt;'+data[i].body+'&lt;/div&gt;'); div.find('ul li:last').append('&lt;div&gt;' + data[i].footer + '&lt;/div&gt;'); } div.insertBefore('#header'); } }); */ </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload