I am creating some JSON on the fly, serializing it and saving it to the DB.
To run it, i create a script element, and load it that way.
Is there a way to load the script source to a textarea?
I'm in the process of designing this site http://www.parisgaa.org/parisgaels and have a problem.
The image slider on the homepage messes up sometimes. Most of the time it works and looks fine, but other times its positioning seems to get messed up and it appears underneath the content that should be below it (i.e. with that content overlapping the image). You should be able to replicate this in Chrome - just refresh a couple of times.
I'd appreciate any help at all.
So, I am working on a project which requires me to call upon a function to get data from an external source.
The issue I am having, I call upon the function - However the code after the function call is continuing before the function has returned a value.
Here is the function -
function getData()
{
var myVar;
var xmlLoc = $.get("http://ec.urbentom.co.uk/StudentAppData.xml", function(data) {
$xml = $(data);
myVar = $xml;
console.log(myVar);
console.log(String($xml));
localStorage.setItem("Data", $xml);
console.log(String(localStorage.getItem("Data")));
return myVar;
});
return myVar;
console.log("Does this continue");
}
And here is where it is called upon -
$(document).on("pageshow","#Information",function() {
$xml = $(getData()); //Here is the function call
console.log($xml); //However, it will instantly go to this line before 'getData' has returned a value.
$xml.find('AllData').each(function() {
$(this).find('item').each(function() {
if ($(this).find('Category').text()=="Facilities") {
console.log($(this).find('Title').text());
//Do stuff here
} else if ($(this).find('Category').text()=="Contacts" || $(this).find('Category').text()=="Information") {
console.log($(this).find('Title').text());
//Do stuff here too
}
});
$('#informationList').html(output).listview().listview("refresh");
console.log("Finished");
});
});
Right now, I'm unsure of why it is not working. My guess is that it is because I am calling a function within a function.
Does anyone have any ideas on how this issue can be fixed?
I have a site where authentication is done externally (which I can't access), so I'm creating a cookie on login in order to display a welcome message to the user. Creating the cookie works fine, I write to document.cookie when the login form submits.
But deleting the cookie doesn't work. Here's my code (logout.php does the external authentication stuff):
<a href="http://external.com/logout.php" style="float:right"
onclick="document.cookie='BRLOG=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/; domain=.example.com;'">Logout</a>
I have two click-events, that are nearly similar, but not quite. I am wondering how to refactor them best:
$('.remove_fields.dynamic').live('click', function(e) {
var $this = $(this);
var after_removal_trigger_node = $this.closest(".nested-fields").parent();
trigger_removal_callback($this);
e.preventDefault();
$this.closest(".nested-fields").remove();
trigger_after_removal_callback(after_removal_trigger_node);
});
$('.remove_fields.existing').live('click', function(e) {
var $this = $(this);
var after_removal_trigger_node = $this.closest(".nested-fields").parent();
trigger_removal_callback($this);
e.preventDefault();
$this.prev("input[type=hidden]").val("1");
$this.closest(".nested-fields").hide();
trigger_after_removal_callback(after_removal_trigger_node);
});
As you can tell there is a fair bit of overlap. I am wondering what the best/nicest way would be to refactor this code.
var blah = Some.Thing(data, function(a,b) {
// code here
});
Some.Thing = function(data, callback) {
var a = Other.Thing(data, function() {
});
};
My question is, will the part that says //code here fire ONLY after everything else and their callbacks fire?
The //code here part seems to fire, and there seems to be some timing issue.
My code is:
<select name='main'>
<option>Animals</option>
<option>Food</option>
<option>Cars</option>
</select>
<select name='other'>
<option>Rats</option>
<option>Cats</option>
<option>Oranges</option>
<option>Audi</option>
</select>
How do I filter my second select, so it would only show items which I want eg. if I Choose Animals, my select would be:
<select name='other'>
<option>Rats</option>
<option>Cats</option>
</select>
and if I choose Food, my select would be:
<select name='other'>
<option>Oranges</option>
</select>
Well, I hope you get the idea. Thanks.
Hi All,
I have a js code:
window.onload = function() {
document.getElementById("Button1").onclick = function() {
var t1 = document.getElementById("Text1").value;
var t2 = document.getElementById("Text2").value;
document.URL = 'myurl?t1=' + t1 + '&t2' + t2;
}
}
Here i am adding t1,t2 as query param..now my question is lets say i have entered some data in Textbox1 but not in textbox2, in that case the url I am getting is
'myurl?t1=' + value of textbox1 + '&t2' + This will be blank;
I want to make it dynamic, i.e.if there is not value in Textbox2 then I dont want to append queryparam t2, same goes for t1 also..isit possible?
I noticed this situation in my code (unfortunately), and was able to duplicate it in my own JS file. So I have this code:
var date1 = new Date(); // today
var date2 = date1;
date2 = date2.setDate(date2.getDate() + 1);
// what is date1?
After this code executes, date1 is today's date + 1! This harkens back to my undergrad days when I learned about pointers, and I guess I'm a little rusty. Is that what's happening here? Obviously I've moved the assignment away from date1, and am only modifying date2, but date1 is being changed. Why is this the case?
Incidentally, after this code executes date2 is a long number like 1272123603911. I assume this is the number of seconds in the date, but shouldn't date2 still be a Date object? setDate() should return a Date object...
Thanks for the help.
Hi Stackoverflow,
I have been looking at the source code of raphael (http://raphaeljs.com/index.html) and I see a lot of stuff like !variable && function() (e.g.: !svg.bottom && (svg.bottom = this); )
What does that exactly do? Does it check first and execute only if not true?
Thanks.
Hi, I have an Ajax function which will retrieve some RSS feed script from server. I put this responsetext in a div using:
$("#divId").html(responsetext);
I want to execute the script inside the response. Currently, the RSS feeds not showing in the div. Is there any way to do that ? thanks..
HI, i need a greasemonkey code for a web page. The page has hidden input type and value. I need a gm script which can alert the value of the hidden input object as soon as the page loads.
The input tag is present in a form with:
form id="bloog" method="post" action= "/newpage.php" name="bloog"
The hidden content is present as:
<input type="hidden" value="abcd" name="ans">
now as soon as the page loads the value abcd must come in the alertbox.. some body please help me i've been trying for these...
Hello all
I'm trying to search for '[EN]' in the string 'Nationality [EN] [ESP]', I want to remove this from the string so I'm using a replace method, code examaple below
var str = 'Nationality [EN] [ESP]';
var find = "[EN]";
var regex = new RegExp(find, "g");
alert(str.replace(regex, ''));
Since [EN] is identified as a character set this will output the string 'Nationality [] [ESP]' but I want to remove the square brackets aswell. I thought that I could escape them using \ but it didn't work
Any advice would be much appreciated
I have a regular HTML page with some images (just regular IMG HTML tags). I'd like to get their content, base64 encoded preferably, without the need to redownload the image (ie. it's already loaded by the browser, so now I want the content).
I'd love to achieve that with Greasemonkey and Firefox.
I'm trying to extract some results from a download manager, the format is:
[#8760e4 4.3MiB/40MiB(10%) CN:2 DL:4.9MiB ETA:7s]
what I'd like to extract from the above example, would be an array that looks like this:
['4.3','MiB','40','MiB','10%','4.9','MiB','7','s']
I've tried to split this in various combinations, but nothing seems to be right. Would anyone happen to know how to do this or be able to offer suggestions?
Thank you!
Hi i am trying to handle an ajax json response
here is my code
success: function (j) {
switch(true)
{
case (j.choice1):
alert("choice2");
break;
case (j.choice2):
alert("choice2");
break;
default:
alert("default");
break;
}
}
based on what j is return i do my action BUT i keep getting the default.
I have alert the j values and come correct.Some how case (j.choice1) case (j.choice2) is not working.
I tried case (j.choice1!="") (j.choice2!="") But in this scenario i keep getting the first choice.
What am i missing
i need to save an image file to client side ,, with out prompting the save,open,cancel dialog , or any similar thing , after long searching i heard that will this will be done only by ActiveX.
please note that the website is on minimum security and its LocalSite and trusted site
window.addEventListener('unload', function(e)
{
MyClass.shutdown();
window.removeEventListener('unload',
/* how to reference the function itself here? */);
}, false);
The question in the comment.
I am attempting to set a cookie to a site using jQuery, ONLY if the user came from a specific site. In this case, lets use -http://referrersite.com- as the site they must come from for the cookie to be created as an example. The cookie value is being stored in a variable and everything up to this point is working fine.
There is a conditional statement checking whether the user came from the referred site, if the cookie exists already and if the cookie doesn't exist and the user did not come from the referred site. If the user came from the referred site the cookie is created and stored in a variable. If the cookie already exists, it is then stored in a variable. If the cookie does not exist and the user did not come from the referred site I am assigning the variable a static string of characters - this is where the issue lies.
When the variable is alerted from the non referred site and no existing cookie, it returns: [object Object], not the static string of characters.
The code I am using is below:
$(document).ready(function() {
var referrer = document.referrer;
if(referrer == "http://referrersite.com") {
$.cookie("code","123456", { expires: 90, path: '/' });
cookieContainer = $.cookie("code");
alert(cookieContainer);
} else if($.cookie("code")) {
cookieContainer = $.cookie("code");
alert(cookieContainer);
} else if($.cookie("code") == null && referrer != "http://referrersite.com") {
cookieContainer = "67890";
alert(cookieContainer);
}
});
Please let me know if there is something I am missing as the code to me looks like it should work.
Thanks!
I already tested with 2 inputText, It runs well
for example
var tdate = document.getElementById('txtDate'); //h:inputText
var tdt = document.getElementById('txtDateTime'); //h:inputText
tdate.onchange = function(){
tdt.value = tdate.value;
};
How can I change the value of " tdt " - h:outputText?
var tdate = document.getElementById('txtDate'); //h:inputText
var tdt = document.getElementById('txtDateTime'); //h:outputText
I also want the books to be no older than 1 year old. And by textbook i mean i want the author(s) to go into the syntax,semantix,structure of the programming language as well as provide questions/mini projects to test what you learned after every section/chapter.
Hello.
So continue from this:
http://stackoverflow.com/questions/2715295/linking-how-php-html
Please check the answer i accepted, and i used the "BASEDIR" solution zneak came with.
Now i ran onto another problem.. in my ajax_framework.js i have:
$.ajax({url: "session.php", success: function(data){
how should i include BASEDIR onto this? i was thinking something about:
$.ajax({url: "'.BASEDIR.'session.php", success: function(data){
but this isnt PHP, so i think you cant? no? any help or maybe another method to come around this?