Hi all -I
Does anyone have experience with jQuery? I just started using it for a web page project, and I've run into an issue with the .get and .ajax functions.
want to populate a div with the contents of a file, and I've noticed it works
fine when my files are up on a server, but when viewing my page on my local computer, it doesn't work. Why might that be?
Nightfox
Ajax requires a web server because the page making the ajax request is doing by http not by the client (i.e. your web browser) trying to open a file.
Re: jQuery .get and .ajax functionsing
By: Trash80 to Nightfox on Sat Feb 05 2011 14:03:52
Ajax requires a web server because the page making the ajax request is do
by http not by the client (i.e. your web browser) trying to open a file.
But I've been able to do ajax stuff without a web server.. A while ago, I wrote a function to return an XMLHttpRequest object (supporting several different browsers), and it works whether it's on a server or on my local machine..
Eric
Then how you implemented wasn't actually using "ajax" (I'd have to see your code). Ajax infers an asynchronous request to a server that returns XML to calling client. If you are doing something off your local machine without a server then there is nothing returned to the client via http. The key here via http. Maybe what you did was open a file and get the contents. But tha is not ajax.
Re: jQuery .get and .ajax functions
By: Trash80 to Nightfox on Wed Feb 09 2011 19:04:59
Then how you implemented wasn't actually using "ajax" (I'd have to see yo code). Ajax infers an asynchronous request to a server that returns XML calling client. If you are doing something off your local machine withou server then there is nothing returned to the client via http. The key he via http. Maybe what you did was open a file and get the contents. But is not ajax.
I was using an XMLHTTP object to fetch the contents of another file and put contents into a div on the page. I thought that was AJAX.
Nightfox
wow I always thought the ajax function was for doing dishes.
Re: jQuery .get and .ajax functions
By: Corey to Nightfox on Wed Feb 09 2011 20:27:39
wow I always thought the ajax function was for doing dishes.
I also like Comet.
Me too. Comet does a good job on my java machine.
Re: jQuery .get and .ajax fun
By: Nightfox to Corey on Wed Feb 09 2011 10:31 pm
Re: jQuery .get and .ajax functions
By: Corey to Nightfox on Wed Feb 09 2011 20:27:39
wow I always thought the ajax function was for doing dishes.
I also like Comet.
Me too. Comet does a good job on my java machine.
Does anyone have experience with jQuery? I just started using it for a web page project, and I've run into an issue with the .get and .ajax functions. I
want to populate a div with the contents of a file, and I've noticed it works fine when my files are up on a server, but when viewing my page on my local computer, it doesn't work. Why might that be?
Ajax requires a web server because the page making the ajax request is doing so
by http not by the client (i.e. your web browser) trying to open a file.
You need to set yourself up with a web development environment. If you are using Linux then just install Apache. If you are using Windows go grab yourself something like WAMP (http://www.wampserver.com/en/) which makes installing and managing Apache simple.
Trash80 wrote:
Ajax requires a web server because the page making the ajax request is doi by http not by the client (i.e. your web browser) trying to open a file.
You need to set yourself up with a web development environment. If you ar using Linux then just install Apache. If you are using Windows go grab yourself something like WAMP (http://www.wampserver.com/en/) which makes installing and managing Apache simple.
For rough dev/testing VS Express web, or MonoDevelop are decent options.
--
Michael J. Ryan - http://tracker1.info/
... Immortality consists largely of boredom.
For rough dev/testing VS Express web, or MonoDevelop are decent options.
I'll take my Mac with extra pickles.
Does anyone have experience with jQuery? I just started using it for a we page project, and I've run into an issue with the .get and .ajax functions want to populate a div with the contents of a file, and I've noticed it wo fine when my files are up on a server, but when viewing my page on my loca computer, it doesn't work. Why might that be?
Browser limitation, see: XmlHttpRequest object.
Browser limitation, see: XmlHttpRequest object.
But a while ago, I was doing some Ajax stuff with XmlHttpRequest without jQuery, and it worked on my local drive too..
Nightfox
Post your code (the one that isn't working for you).
Post your code (the one that isn't working for you).
Here it is:
// Loads a page in a div.
function loadPageInDiv(pFilename, pDivName) {
// Load the new file in the specified div.
$.get(pFilename, {}, function(responseText){
$("#" + pDivName).html(responseText);
});
}
Nightfox
$.get requires a server as it is requesting the URL via HTTP GET. Try using jQuery's load like so:
$("#"+pDivName).load(pFilename);
Re: Re: jQuery .get and .ajax functions
By: Trash80 to Nightfox on Thu Mar 10 2011 17:34:52
$.get requires a server as it is requesting the URL via HTTP GET. Try us jQuery's load like so:
$("#"+pDivName).load(pFilename);
Thanks for the response. I tried using load, but it still doesn't work when run my web app locally.
Nightfox
Thanks for the response. I tried using load, but it still doesn't work w run my web app locally.
Now that is odd. I tested the above locally on my computer and it worked. H you tested with different web browsers?
I still think you should set yourself up with a "proper" :) testing environment. You're using Windows if I remember correctly. Try out WAMP (Windows, Apache, PHP, MySQL). It makes running an AMP stack about as easy it gets.
Now that is odd. I tested the above locally on my computer and it worked. Have
you tested with different web browsers?
I still think you should set yourself up with a "proper" :) testing environment. You're using Windows if I remember correctly. Try out WAMP (Windows, Apache, PHP, MySQL). It makes running an AMP stack about as easy as
it gets.
http://www.wampserver.com/en/
I could just set it up on a server of mine and show them). Also, I thought was weird that I used to be able to do it, but not now..
Nightfox
WebPI makes getting WIMP (Windows, IIS, MySQL, PHP) pretty straight forward http://www.microsoft.com/web/platform/
It's actually pretty nice for getting up and running web dev, or software in windows.
--
Michael J. Ryan - http://tracker1.info/
Re: Re: jQuery .get and .ajax functions
By: Trash80 to Nightfox on Mon Feb 21 2011 17:47:18
Post your code (the one that isn't working for you).
Here it is:
// Loads a page in a div.
function loadPageInDiv(pFilename, pDivName) {
// Load the new file in the specified div.
$.get(pFilename, {}, function(responseText){
$("#" + pDivName).html(responseText);
});
}
Nightfox
---
■ Synchronet ■ Digital Distortion BBS: digdist.bbsindex.com
Sysop: | Eric Oulashin |
---|---|
Location: | Beaverton, Oregon, USA |
Users: | 105 |
Nodes: | 16 (0 / 16) |
Uptime: | 07:26:40 |
Calls: | 5,571 |
Calls today: | 1 |
Files: | 8,493 |
D/L today: |
654 files (550M bytes) |
Messages: | 357,183 |