Ajax :: Possible To Get Multiple Variables From External File?

Jul 20, 2009

I have used AJAX lots before and I wondered if it was possible to set variables from an AJAX file E.g. an ajax file could set
var set1 = 10;
var set2 = 55;
with both variables coming from an external file called by AJAX. Which JS side perform the request and the format of the file that is requested.

View 4 Replies


ADVERTISEMENT

Passing GET Variables To An External File?

Dec 2, 2009

I used to have a traffic tracking script that used to work as follows:

Code:
<script type="text/javascript">
var tracking_image = new Image;
tracking_image.src = '/track.php' +
'?page=' + escape(document.location.href) +
'&referrer=' + escape(document.referrer);
</script>

This would interact with a PHP file which parsed this information and stored it in a database. However I just changed servers, and for some reason this JavaScript no longer works; don't know if it was because of the server move or what.

Is there any way to pass GET variables to an external javascript file? I would like to pass things like document.location.href and document.referrer to a PHP file. For instance something that would function like

Code:
<script src="/track.php?page=" + escape(document.location.href) + "&referrer=" + escape(document.referrer)>
</script>

Or alternatively, perhaps there is some other way for a PHP file to access JavaScript's document.location.href and document.referrer values (I'm using JavaScript to access this info rather than standalone PHP since spiders don't activate JS).

View 3 Replies View Related

How Do I Get Variables In External JS File To Work In Html Page?

Jul 14, 2007

I need help getting variables in an external js file to transfer to the html page that uses them. I have an html page that lists verses to memorize, which, when the mouse hovers over a particular verse, a small popup reveals the book reference for that verse, thus giving a check to see if the user has accurately referenced that verse for its source.

I have an external js file (VERSES.js) that houses the verses and popup references sequentially as elements in an array and then writes them to the html document. A simplifed version of what I am using, with only a few verses listed here as an example, and that works beautifully, is given below: Code:

View 6 Replies View Related

AJAX :: Pass Multiple Variables From PHP ?

Jul 8, 2010

I'm using AJAX to, on the click of a button, run a PHP script that dynamically generates a new line of text, and passes that to the script.The PHP script, new_sentence.php, just echos out the sentence.This works fine.But what I would like to do is for the PHP script to dynamically change JavaScript variables.how to pass multiple variables from PHP to JS.I can, of course, pass one by having the PHP script echo anything, and then use JS to set the variable to the PHP output. But what if I wanted to set two or three JavaScript variables at once?Here's my code in the HTML page that contacts new_sentence.php:

Code:
function ajaxRefresh(){
var ajaxRefresh;
ajaxRequest = new XMLHttpRequest();[code].....

When I press the "Refresh" button on the HTML page, it runs the ajaxRefresh function, which calls new_sentence.php. Then, once it gets the response, it changes the text of the element named "div" to whatever text the new_sentence.php echos.I'd like to figure out how to get a couple of variables.I would imagine this is simple. how to set the variables in PHP and then how to retrieve them in JS.

View 4 Replies View Related

AJAX :: Pass PHP Multiple Variables?

Oct 19, 2010

I've recently begun using AJAX on my website and have ran into a problem.My webpage: catalogue.php contains a category variable named $cid which the page GETS in order to display products from the correct category. This works fine.I now want to implement a drop-down box to sort by price, name, newest etc...I have tested the AJAX out with a dropdown box for changing the category and it works fine, this is because it is only passing one variable which it gets via the javascript "this.value".

The sort by price box requires two variables to be passed .I can pass the "this.value" which tells the javascript function I want to sort by price/newest/etc but I cannot figure out how to pass the category variable ($cid) so that when the xmlhttp.open calls the url: getSort.php it passes both pieces of info.My javascript is:

Code:
function showSort(str)
{
var cat = <?php echo $cid ?>;[code].....

View 5 Replies View Related

Ajax :: Pass Variables To A Php File?

Mar 23, 2011

I am using this library [url]...

Now i have a doubt, how i can pass the variables $var and $var1 with ajax to a PHP file? to make sql querys and replace the values of $var and $var1[code]...

View 2 Replies View Related

Ajax :: Execute External JS File ?

Jul 24, 2009

How can we execute external JS files using ajax. I tried to set evalScript as true. but for external js files this is not working. Also, is there any way to protect .js files by not allowing users to download it.

View 1 Replies View Related

JQuery :: Send An Ajax Post To An External File

Aug 21, 2009

I've used a few jquery things before, but I haven't a clue when it comes to javascript, so I've mainly just modified variables here and there. This is my first attempt at actually writing something, and well.....its not working

Im trying to send an ajax post to an external file, which simply returns 'Complete' after updating the db. My html gives me an ul, with li elemnts, representing names of comics.

Anyway heres my code:

View 4 Replies View Related

AJAX :: Sending Contents Of Textfield To External File?

Jul 1, 2011

I'm tring to do an AJAX call using a submit button. I need to submit the contents of a textfield to a PHP page.It is working on a <select> tag using the <option> tags to send the contents of the <option> tag to the outside PHP file, but I can't get the syntax right to send the contents of the textfield.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

[code]....

View 2 Replies View Related

AJAX :: Loading And Refreshing Div Every 2 Seconds From A File That Is Passing Variables?

Apr 15, 2010

I am developing a script to work along side my joomla website and i am wanting to develop a script that connects to my database and refresh's certain divs every 2 seconds without the user noticing this,

only issue is that joomla isnt wanting to work with me on this,

Here is my code,

Code:
<script src="http://code.jquery.com/jquery-latest.js"></script>
$user =& JFactory::getUser();
if($user->username)

[Code]....

since when i do that i get nothing on my navagation where user information is displayed and displays the enter layout in the div right_contenta So can jquery does this.

How can i fix this and get my right_contenta div refreshing every 2 seconds with my joomla layout

in otherwords i want my ajax to load and refresh the information located at profile2.php?user=admin which has all user information coming fom database and refreshs every 2 second

View 2 Replies View Related

AJAX :: Retrieve Multiple Values From Php File Using It?

May 12, 2009

How would i retrieve multiple (GET) values from a php file using AJAX..

Say i had the following function that ask's for a userID variable - how could i ask for more than one variable instead of just userID? [code]...

View 4 Replies View Related

External .js Not Reading Variables?

Jul 28, 2010


In my XSL I have:

Code:
<script type="text/javascript">
$(document).ready(function() {
var window.amount=<xsl:value-of select="count(/data/fotos/entry)" />;
var window.size= amount * 56;

[Code]....

Simple enought eh? However 'tracing' from code in the HEAD gives me correct values, but from the external .js gives me undefined. The reason I have to put my code away is because of XSL syntax limitations.

View 1 Replies View Related

Reading External Text File - Load The Content Of The File Into A Variable In Script

Jul 16, 2010

I'm writing a script and I've encountered a problem.. I have a txt file with many words, each word in a different line. For example: the file words.txt contains:

word1
word2
word3
word4
word5

I need to load the content of the file into a variable in my script. I prefer that all the words will be in the same variable with line breaks, but if you'll figure out a way to put it in an array, it's ok too. I really don't know how to do it, and I tried to google but didn't understand.. By the way, I don't want to change the txt file to js file, I need it to remain txt..

View 8 Replies View Related

Including A Javascript External File From The <body> Part Of An HTML File

Sep 26, 2007

I got an [object error] from IE 7.0.5730.11 when moving the <script
src="..." type="text/javascript" /tag from the <headpart to the
<bodysection of a HTML file.

Is not possibile to include Javascript code via <script src="..."
type="text/javascript" /from the <bodysection, instead from the
<headone? If yes, anyone has any idea of which the problem could be?
If not, how can I programmatically include a javascript external file
inside the <bodypart of a HTML file, for example, using Javascript
to some particular native functions?

View 1 Replies View Related

Embedded External - .js File Into HREF Tag - Call The Scripting File Though Html

Oct 15, 2011

I have a external file for example abc.js ,in this abc.js file no functions ,it contains some scripting,i want to call the scripting file though html I use the code

<script type="text/javascript src="abc.js"></script>

in the header file but i want it in a href tag

View 1 Replies View Related

Config File + Class/Functions File - Variables Not Found?

Feb 13, 2010

I have a JavaScript config file called gameSetting.js which contains a bunch of variables which configures a particular game. I also have a shared JavaScript library which uses the variables in gameSetting.js, which I include like so:

<script type="text/javascript" src="gameSetting.js" ></script>
<script type="text/javascript" src="gameLibrary.js" ></script>
In gameSetting.js I have:
$(document).ready(function()
{
// call some functions / classes in gameLibrary.js
}

in Firefox, Safari, and Chrome, this works fine. However, in IE, when it's parsing gameSetting.js, it complains that the functions that live in gameLibrary.js aren't defined. When it gets to parsing gameLibrary.js, the variables in gameSetting.js are reported as not being defined. I've tried dynamically bootstrapping the gameLibrary file using this function in document.ready for dynamic load.

However, the same problem still happens in IE, where when it parses the files individually it's not taking into context the file/variables that came before, so it's not an out of load order problem.

My options are:

1) collapsing all the functions in gameLibrary.js and variables in gameSetting.js into one file. However, this is not practical because this is dealing with literally hundreds of games, and having a gameLibrary.js in ONE location for ONE update is what makes most logical sense.

2) figure out a way to get this to work where variables in file1 are accessible to file2 in IE (as it seems they are in other browsers).

jQuery seems to be able to have multiple plugins that all refer to the based jQuery-1.3.2.js, so I know there is a way to get this to work.

View 1 Replies View Related

External Txt File - Load The Content Of The File Into A Variable In Script

Jul 16, 2010

I'm writing a script and I've encountered a problem.. I have a txt file with many words, each word in a different line. For example: the file words.txt contains:

word1
word2
word3
word4
word5

I need to load the content of the file into a variable in my script. I prefer that all the words will be in the same variable with line breaks, but if you'll figure out a way to put it in an array, it's ok too. I really don't know how to do it, and I tried to google but didn't understand.. By the way, I don't want to change the txt file to js file, I need it to remain txt..

View 5 Replies View Related

Txt File - Write Information To A Log File That's On An External Site

Feb 26, 2010

Is it possible to use javascript to write information to a log file that's on an external site? What I want to do is have a person put their name and birthday into a form on my site, and then output that information to a partnering site's log file which would be something like www.whatever.com/whatever.file Is this possible? what file type can javascript write to? I put .file because I am unsure.

View 6 Replies View Related

Syntax Error On External JS File Beyond End Of File

Oct 14, 2005

I have the following HTML file:
---
<html>
<head>
<title>Test</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
Hi There. <a href="javascript:doit()">Click Me</a>
</body>
</html>
---

The following js file:
--
function doit() {
alert("I did it");
}
--

Running htm file locally (double click) gives me security warning (XP
SP 2) but if I then select "allow script to run" everything works fine.

But when I serve page through IIS (localhost) I get a syntax error line
4 char 4. Of course there is no line 4 in the js file.

This HAS to be something simple I am missing but I have tried:
- with and without language attribute in script tag
- relative and absolute paths for the js file
- with and without Mime type for js set in IIS

Only remaining thing I guess it could be is file permissions but
everything has execute on it as far as I can see.

View 7 Replies View Related

JQuery :: Get A Script File To Loop Through Multiple Sections Of A Xml File?

Apr 11, 2010

I'm working on this project where I'm trying to use jquery to read from an xml file and generate added code to a html index file by creating dropdown select menus and then allowing the user to display pictures according to what of the 2 category 'select' types they select on the dropdown list.

The program works as far as generating the select dropdown list but only generates the images for the first selected option. When I select the second drop down category nothing happens it simply shows the pics from the first category. When I go into firebug and display the html file after the script is run there are an extra set of <p> tags without anything in them. I traced through the script and can't find where the <p></p> is coming from. It's not on the initial html page. I have the script below for the xml and jq.

<?xml version="1.0" encoding="ISO-8859-1"?>
<gallery>
<picture class="House and Home">
<listing>Pics/HouseHome/h1.jpg</listing>

[Code]......

View 2 Replies View Related

How To Validate Multiple JS Variables

Jun 29, 2010

The following works in php but not in javascript.
if((dobyear==false) && (dobmonth==false) && (dobday==true))
{
return 'noyearmonth';
}

View 3 Replies View Related

Assign Multiple Variables At Once?

Mar 16, 2010

Is it possible to assign multiple variables at once? For example:

var int1,int2,int3,int4,int5 = 0

I'm just wondering because I did this without thinking and my program never gave me an error and everything worked fine. Is it because these variables are set to 0 by default or what? If it does work, are there any other languages that this works in such as vbscript?

View 4 Replies View Related

Passing Multiple Variables Via Url

Sep 12, 2003

I'm trying to pass multiple variables using a url on a Java function call.
the code I have that passes the 1 variable is:

function HandleChange() {
parent.CustomerIf.document.location.href="CustomerReturn.asp?id=" + varName.options[varName.selectedIndex].text;
}

which passes the chosen data (being loaded from a database) from a drop down box on an onchange event in asp script.

What I want to do is pass multiple variable via the above url script that the next page will get by the request.querystring method.

something like this:

function HandleChange() {
parent.CustomerIf.document.location.href="CustomerReturn.asp?id=" + varName.options[varName.selectedIndex].text + "address=" varAddress.value;
}

View 4 Replies View Related

Get Css From External File?

Nov 4, 2011

I'm having a bit of trouble understanding something that seems relatively simple. When I make changes to CSS in JavaScript using '.style' I'm changing the attribute values of inline CSS. Can I use JavaScript to change the attribute values of rules in an external CSS file? I have no CSS in my html and would like to know if I can grab the values of attributes in an external CSS file using JavaScript.

View 2 Replies View Related

Passing Multiple Variables With JavaScript

Jul 23, 2005

I'm having a problem passing a variable through a URL because the
variable is supposed to hold a URL that has a variable of its own.
Here is an idea of what I'm trying to do:

href="javascript:
newWin('/vcrc/exitvcrc.jhtml&newURL=http://www.something.net/default.asp?sponID=ETC','NowLeaving',&#39420;',
&#39200;', 'no', 'auto','no');"

So, pretty much, the page I'm sending the variable to think there's two
variables (newURL and sponID), but sponID is part of the URL.

View 2 Replies View Related

JQuery :: Passing Multiple Variables With 1.3.2?

Nov 3, 2009

I'm trying to pass data to my mySQL database, but I'm doing that 2 jQuery scripts:User comes on my page where there is a list with some values, e.g 530, 532, 534 etc etc ..User clicks on one of them, this link is using the jQuery to get another php file which get's the data from my DB and list it below the first list, here's the code for this:

$('#letter-e a').click(function(){
$.get('e.php', {'depot': $(this).text()},function(data){
$('#dict').html(data);

[code].....

So the second list is another step that can't be avoided to get the final result. In other words, i'ts another list where the user has to chose one of the items from the list to see the final result, I've added this code inf the 'e.php' file:

$('#letter-f a').click(function(){
$.get('f.php', {'date': $(this).text()},function(data){
$('#entry2').html(data);

[code].....

The problem is that my 'f.php' only gets 1 variable value, but I'll need 2 or more (maybe in the futur), how to pass multiple variables to a php file using jQuery?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved