Re: [jQuery] Response converted to entities after file upload
Are you using a Php framework? If so, does it do output filtering? If not, can you show me your Php code? Randy 2010/2/17 Lay András laysoftjqu...@gmail.com: Hi! If i have a file upload input in my form, after submit the html codes in the response data converted to their entities: http://bogex.hu/jquery_upload_test.php How can I prevent this? Thank you! Lay -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Response converted to entities after file upload
A couple of things to try. First, run phpinfo() and look through the output for anything that could be filtering the output. Second, try using double quotes or echo or print() in place of die() and follow with exit. die() does not escape html (at least not on my servers) so I suspect that phpinfo() will show something that is filtering your output. 2010/2/17 Lay András laysoftjqu...@gmail.com: Hello! On Wed, Feb 17, 2010 at 5:56 PM, Randall Morgan rmorga...@gmail.com wrote: Are you using a Php framework? If so, does it do output filtering? If not, can you show me your Php code? It's a simple PHP code, without any framework. The source code visible, you can simply copy, and check it on your server. Now i put a alert, to view the server response immediately. My problem is, the h1 and /h1 elements converted to lt;h1gt;f and lt;/h1gt; entities. This only happens, when the file input is present in the form. I mean the problem occurs, when the form submitted to an iframe... Lay -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Response converted to entities after file upload
You may want to remove the $header method. PHP should send the content-type text/html header by default. Randy On Wed, Feb 17, 2010 at 11:41 AM, Randall Morgan rmorga...@gmail.com wrote: A couple of things to try. First, run phpinfo() and look through the output for anything that could be filtering the output. Second, try using double quotes or echo or print() in place of die() and follow with exit. die() does not escape html (at least not on my servers) so I suspect that phpinfo() will show something that is filtering your output. 2010/2/17 Lay András laysoftjqu...@gmail.com: Hello! On Wed, Feb 17, 2010 at 5:56 PM, Randall Morgan rmorga...@gmail.com wrote: Are you using a Php framework? If so, does it do output filtering? If not, can you show me your Php code? It's a simple PHP code, without any framework. The source code visible, you can simply copy, and check it on your server. Now i put a alert, to view the server response immediately. My problem is, the h1 and /h1 elements converted to lt;h1gt;f and lt;/h1gt; entities. This only happens, when the file input is present in the form. I mean the problem occurs, when the form submitted to an iframe... Lay -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Is there have any JQuery plugin that can sort 1A,2A,3A,... 10A, 11A, 12A, 13A, 14A?
Hi, I'm not sure what DBMS you are using but most can sort many ways. You may want to read your DBMS manuals and look for a natural sort method. MySQL uses something like ORDER BY column_name NATURAL ASC or ORDER BY column_name NATURAL DESC. Somewhere on the net should be an old thread about sorting mixed numbers and alpha characters in MySQL. Try Googling the topic. If the DB can handle the sort for you, you'll save time and network traffic. Unless you really need to be able to sort this on the client side. Hope this helps Randy On Tue, Feb 2, 2010 at 8:37 AM, HenryRock henryloke.myetr...@gmail.com wrote: I facing a problem in sorting : 1A,2A,3A,... 10A, 11A, 12A, 13A, 14A Sample data. I using the SQL to sort ASC but it return result as below: 12A 13A 14A 10A 11A 1A 2A 3A 4A 5A 6A 7A 8A 9A May I know is there have any plugin that can sort the sample data above to 1A until 14A? Thanks... -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Replacing a portion of an href value
Hello, I have the following code which is part of a loop to add preview images to a filmstrip where each cell is made up pf a div. My filmstrip uses a tiny bw version of the image which is stored in the images/s/ folder. My preview images must come from the images/m/ folder. I have tried using replace() but have not been successful at it. Any help would be greatly appreciated. Code: $(body).append(div id='preview'img src='+ this.href +' alt='Image preview' /+ c +/div); Original href's are similar to: sitename.com/images/s/image_name.png I need the following replacement: sitename.com/images/m/image_name.jpg So I need to replace the sub-folders and the file extensions within the line above. Thanks, Randy -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Replacing a portion of an href value
Hi, actually my image names (35 of them) as coming from an ajax call and I loop through the results assigning the images to the filmstrip cells. Then I setup the mouse overs for the popup preview. If this were php or C I'd have not trouble. But with Javascript and JQuery I'm lost... On Mon, Feb 1, 2010 at 6:13 PM, Andreas Möller localhe...@l8m.de wrote: I don't know about regular expressions in Javascript, but actually you just want to match the name of the image and prepend it with a different path and append a different suffix to, so something like preg_match('/^\com\/images\/s\/([a-z0-9_])+\.png$/', $href, $match); $href = 'com/images/s/' . $match[1] . '.png'; - only in Javascript. Best regards, Andreas -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Replacing a portion of an href value
Hi All, I figured it out. I was making it far more complex than it needed to be ;-) this.href.replace('/s/', '/m/') Thanks, On Mon, Feb 1, 2010 at 6:31 PM, Randall Morgan rmorga...@gmail.com wrote: Hi, actually my image names (35 of them) as coming from an ajax call and I loop through the results assigning the images to the filmstrip cells. Then I setup the mouse overs for the popup preview. If this were php or C I'd have not trouble. But with Javascript and JQuery I'm lost... On Mon, Feb 1, 2010 at 6:13 PM, Andreas Möller localhe...@l8m.de wrote: I don't know about regular expressions in Javascript, but actually you just want to match the name of the image and prepend it with a different path and append a different suffix to, so something like preg_match('/^\com\/images\/s\/([a-z0-9_])+\.png$/', $href, $match); $href = 'com/images/s/' . $match[1] . '.png'; - only in Javascript. Best regards, Andreas -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Lists, Filtering and Searching, Oh My!
Would it not be better to provide a server side script such as php or asp to allow a paged, sorted, ajax call. Even if you put all this data in an access database or xml file the server side script can parse and return a small chuck of data reasonably fast. At 1800 records I'd opt for a database write a script to import/export to-from csv for that the list management can be done via xcell or similar app. On Tue, Jan 19, 2010 at 12:06 PM, John Arrowwood jarro...@gmail.com wrote: json is one approach. XML is another. CSV works, too. The format of the file should be what works best for the people that need to maintain it. Then, you need to find a good way of getting that data into the browser and in a format that is easy to work with. How often does this file change? Is this something that can be loaded at the beginning of the user session and then cached? Or do you need to update the user's view regularly? That is, do you need multiple ajax calls, or just load it all in on page load? If it were me, using Excel to manage the list, and exporting to CSV, then loading and parsing that is probably what I would do. Just make sure your CSV parsing code is bug-free. :) When you load and parse the CSV, just load each record into an object in an array. Piece of cake. Then you build your display based on the array, sorting and/or filtering as you do so, based on what the user needs. That last part has the potential to be a slightly sticky piece of cake if you tried to do it all yourself, but even then it is doable. Using the QuickSearch might work, but looking at the sample, it's pretty slow with even a small list (looking at the table example), so with such a large data set, it may not be much fun. Won't know until you try. There are also plugins (are there not?) which turn tables into sortable/searchable data sets. You could build one of those as an 'alternative possibility' for your users to look at. On Tue, Jan 19, 2010 at 4:54 AM, david.vansc...@gmail.com david.vansc...@gmail.com wrote: A while back, the company I work for tasked me with coming up with a better way to move through a listing of forms on our Intranet. The way it was done before involved two identical files being maintained simultaneously, one sorted by the form ID (AA0001) and the other by name. The list of forms is nothing to sneeze at ... the first page includes a list of over 1800 forms. My first stab at a solution moved everything into a single unordered list. I was able to assign classes to each list item for the alpha character, the ID and type. Clicking on the appropriate links would show only those items which you selected. I also plugged in Rik Lomas' awesome QuickSearch plugin to quickly search the list. The only drawback was that the group responsible for maintaining the list of forms had to choose whether they wanted the list sorted by name or form ID. They chose name. Last week though, they decided that wasn't good enough and they needed to be able to sort by either name or form ID, so I've been handed this project again and told to make it work more to their liking. A table would break from the way they've organized these forms for years now, so they're really not interested in something like that, so it'd really need to be a list. The forms need to be able to be sorted alphabetically by name or form ID as well as organized by category. My first idea was to build a big (and I mean BIG) JSON file that would store all the information for these forms. I'd then be able to parse through the JSON object and build the list on the fly based on what they clicked. Of course, we're talking about a JSON file that'd probably be over 2000 lines and would have to be parsed every time they click something (I'm not sure if I could call in the JSON file and have it available instead of using $.getJSON). Then there's the issue of searching. Obviously QuickSearch works great, but how am I going to search through a static file without throwing everything on to the page? As you can see, I've begun brainstorming some ideas, but I'd really love to hear what other solutions come to mind for you guys. Any ideas you have would be awesome. Thanks! David -- John Arrowwood John (at) Irie (dash) Inc (dot) com John (at) Arrowwood Photography (dot) com John (at) Hanlons Razor (dot) com -- http://www.irie-inc.com/ http://arrowwood.blogspot.com/ -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Looping help
Hello, I'm still pretty new to JQuery and I need to figure out how to loop over a json array and assign the array values to each of a list of divs. What I need to do is fill each filmstrip-cell with an image tag and set the source to the current value in the array. The array contains urls for each of 35 images. My code is similar to: div id=filmstrip class=filmstrip div id=1 class=filmstrip-cell /div div id=2 class=filmstrip-cell /div div id=3 class=filmstrip-cell /div div id=4 class=filmstrip-cell /div ... div id=35 class=filmstrip-cell /div /div -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] Looping help
Here is a print out of the Json array returned from my php script. [http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0853.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0855.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0856.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0857.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0858.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0860.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0859.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0861.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0862.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0863.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0864.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0847.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0849.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0851.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0845.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0846.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0850.JPG,http:\/\/localhost\/f-stopart2\/photoshoots\/n\/PICT0848.JPG] Thank you for you help On Mon, Jan 11, 2010 at 10:25 PM, John Arrowwood jarro...@gmail.com wrote: What does your JSON array look like? On Mon, Jan 11, 2010 at 9:23 PM, Randall Morgan rmorga...@gmail.com wrote: Hello, I'm still pretty new to JQuery and I need to figure out how to loop over a json array and assign the array values to each of a list of divs. What I need to do is fill each filmstrip-cell with an image tag and set the source to the current value in the array. The array contains urls for each of 35 images. My code is similar to: div id=filmstrip class=filmstrip div id=1 class=filmstrip-cell /div div id=2 class=filmstrip-cell /div div id=3 class=filmstrip-cell /div div id=4 class=filmstrip-cell /div ... div id=35 class=filmstrip-cell /div /div -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? -- John Arrowwood John (at) Irie (dash) Inc (dot) com John (at) Arrowwood Photography (dot) com John (at) Hanlons Razor (dot) com -- http://www.irie-inc.com/ http://arrowwood.blogspot.com/ -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
Re: [jQuery] How should I structure this?
On the backend you could add a timestamp for when items are added to the database. Then your query would return anything with a timestamp newer than the last time you asked for items. in client js: last_request = time(); Then send the time along with your request to the server script. on the server: ?php $query = select * from `item_table` where `added_on` $_POST[last_request]; ? Hope this helps On Mon, Jan 4, 2010 at 12:11 PM, Apaz b831...@uggsrock.com wrote: Hello Lets say we have a database where things are going to be added at random times, over the whole day. I want a AJAX script to load new items every 5s (its a local database so no problem with spamming it) and for each of these items I have to do a AJAX request to get some more data... From the back-end I will get something like: unique ID time number name text How do I detect which items I already have added to my site? Because If I just get the latest one, there is a chance I miss something, so its safest if the back-end returns the latest 5 items, or? Any example code how to use the unique ID to validate that I got every row I wanted? Am I thinking completely wrong? I have access to the back-end also so I can change what I want.. Help needed! Thanks ;) -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Re: ajax.load(url) working in IE only
Ok, I have a question. My changes seem to work the for the first click but not on subsequent clicks on the navigation. I suspect that the binding is lost when the html code is replaced. Any ideas on how I should attack this issue or if this is in fact what is happening? Is there a way to re-bind the ajax calls to the reloaded anchors in the image navigation? On Thu, Mar 12, 2009 at 2:46 PM, James james.gp@gmail.com wrote: The issue is not the anchor tag around the image. The issue is how your events and actions are working. This is what your script is doing: - A user clicks on the image (the a link) - This call updateGallery() - updateGallery() sets an event - when clicking on any a link with class galleryNavHA, you do the AJAX - End This doesn't actually do the AJAX. It just binds a click event. Suppose a user clicks on that (or any) image again: - User clicks on the image - This calls updateGallery() AND the binded event to do the AJAX. - updateGallery() sets another, duplicated, event - when clicking on any a link with class galleryNavHA, you do the AJAX - End What you need to do is bind the click event on page load. If the user has no Javascript enabled, the click binding will not be done, and the a link will do its default job. script $(function() { $(.galleryNavHA).click(function(event){ var href = this.href; var rel = this.rel; // do your ajax stuff return false; }); }); /script a class=galleryNavHA rel=http://hooker.dotnetnebraska.com/ index.php/gallery/getAjaxNavH/4/101 href=http:// hooker.dotnetnebraska.com/index.php/gallery/getAjaxMainImage/4/101 img class=galleryNavHImg src=http://hooker.dotnetnebraska.com/ images/o/30big.jpg //a This keeps the Javascript outside of the HTML also. On Mar 12, 11:18 am, Randall Morgan rmorga...@gmail.com wrote: Hi Yes, I have the anchors because I need to insure there is some functionality when js is not available. I have used anchors with my own ajax code without issue as long as I return false from the js function call. Is this a known issue with JQuery, that you can't provide a default action for an anchor? If it is, how to I insure the image is still available if javascript is turned off? Thank you for you help. On Thu, Mar 12, 2009 at 1:50 PM, mkmanning michaell...@gmail.com wrote: Not looking any further, you have anchors with inline onclick events (not considered good practice btw) which call the updateGallery() function, which then binds a click event on the same anchors, every time you click them again? a onclick=javascript:updateGallery(); class=galleryNavHA... You might want to rethink it a little bit :P On Mar 12, 10:46 am, Monotoba rmorga...@gmail.com wrote: Hello, I have use ajax.load in the following function to load both a main image and an image navigation bar on a single page. The fucntion works in IE but not in FF or Chrome. I am not fluent enough (yet) with javascript or firebug to figure out what is happening. The demo page can be found at:http://hooker.dotnetnebraska.com/index.php/gallery /* * Updates Photo Gallery */ function updateGallery() { $(.galleryNavHA).click(function(event){ event.preventDefault(); var href = this.href; var rel = this.rel; //$(.galleryMainImg).fadeOut(slow); $(.galleryMainImageDivCls).load(href); //$(.galleryMainImg).fadeIn(slow); $(.galleryNavDivCls).load(rel); return false; }); } Any help getting this to work would be greatly appreciated. Thanks, R Morgan -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Re: ajax.load(url) working in IE only
HI James, I had updated to the latest JQuery the other day hoping it would solve my problems. At first I was thinking the issue might be that I was needing some plaugin for non-IE browsers or perhaps there was bug in my version of jquery. I can see now that jquery requires a slightly different mind set and a new set of techniques that I have never used. Being a noob at jquery I truly appreciate your help and the gallery now works with the live method. Thank you so much. I'll be purchasing a book on jquery as soon as I can. DO you have any suggestions? Thanks again for your help. Sincerely, Randall On Fri, Mar 13, 2009 at 12:14 PM, James james.gp@gmail.com wrote: Yes, any new code introduced via something like AJAX would not have the events binded automatically. Using jQuery, you have basically two options: - re-bind the event again - use the new live() function (recommended, requires jQuery 1.3+) For live(), you replace: $(.galleryNavHA).click(function(event) with: $(.galleryNavHA).live(click, function(event) (doc: http://docs.jquery.com/Events/live#typefn) Then you would not have to re-bind again later on. This is using a technique known as Event Delegation. (Nice read: http://lab.distilldesign.com/event-delegation/) On Mar 13, 7:00 am, Randall Morgan rmorga...@gmail.com wrote: Ok, I have a question. My changes seem to work the for the first click but not on subsequent clicks on the navigation. I suspect that the binding is lost when the html code is replaced. Any ideas on how I should attack this issue or if this is in fact what is happening? Is there a way to re-bind the ajax calls to the reloaded anchors in the image navigation? On Thu, Mar 12, 2009 at 2:46 PM, James james.gp@gmail.com wrote: The issue is not the anchor tag around the image. The issue is how your events and actions are working. This is what your script is doing: - A user clicks on the image (the a link) - This call updateGallery() - updateGallery() sets an event - when clicking on any a link with class galleryNavHA, you do the AJAX - End This doesn't actually do the AJAX. It just binds a click event. Suppose a user clicks on that (or any) image again: - User clicks on the image - This calls updateGallery() AND the binded event to do the AJAX. - updateGallery() sets another, duplicated, event - when clicking on any a link with class galleryNavHA, you do the AJAX - End What you need to do is bind the click event on page load. If the user has no Javascript enabled, the click binding will not be done, and the a link will do its default job. script $(function() { $(.galleryNavHA).click(function(event){ var href = this.href; var rel = this.rel; // do your ajax stuff return false; }); }); /script a class=galleryNavHA rel=http://hooker.dotnetnebraska.com/ index.php/gallery/getAjaxNavH/4/101 href=http:// hooker.dotnetnebraska.com/index.php/gallery/getAjaxMainImage/4/101 img class=galleryNavHImg src=http://hooker.dotnetnebraska.com/ images/o/30big.jpg //a This keeps the Javascript outside of the HTML also. On Mar 12, 11:18 am, Randall Morgan rmorga...@gmail.com wrote: Hi Yes, I have the anchors because I need to insure there is some functionality when js is not available. I have used anchors with my own ajax code without issue as long as I return false from the js function call. Is this a known issue with JQuery, that you can't provide a default action for an anchor? If it is, how to I insure the image is still available if javascript is turned off? Thank you for you help. On Thu, Mar 12, 2009 at 1:50 PM, mkmanning michaell...@gmail.com wrote: Not looking any further, you have anchors with inline onclick events (not considered good practice btw) which call the updateGallery() function, which then binds a click event on the same anchors, every time you click them again? a onclick=javascript:updateGallery(); class=galleryNavHA... You might want to rethink it a little bit :P On Mar 12, 10:46 am, Monotoba rmorga...@gmail.com wrote: Hello, I have use ajax.load in the following function to load both a main image and an image navigation bar on a single page. The fucntion works in IE but not in FF or Chrome. I am not fluent enough (yet) with javascript or firebug to figure out what is happening. The demo page can be found at: http://hooker.dotnetnebraska.com/index.php/gallery /* * Updates Photo Gallery */ function updateGallery() { $(.galleryNavHA).click(function(event){ event.preventDefault(); var
[jQuery] Re: ajax.load(url) working in IE only
Hi Yes, I have the anchors because I need to insure there is some functionality when js is not available. I have used anchors with my own ajax code without issue as long as I return false from the js function call. Is this a known issue with JQuery, that you can't provide a default action for an anchor? If it is, how to I insure the image is still available if javascript is turned off? Thank you for you help. On Thu, Mar 12, 2009 at 1:50 PM, mkmanning michaell...@gmail.com wrote: Not looking any further, you have anchors with inline onclick events (not considered good practice btw) which call the updateGallery() function, which then binds a click event on the same anchors, every time you click them again? a onclick=javascript:updateGallery(); class=galleryNavHA... You might want to rethink it a little bit :P On Mar 12, 10:46 am, Monotoba rmorga...@gmail.com wrote: Hello, I have use ajax.load in the following function to load both a main image and an image navigation bar on a single page. The fucntion works in IE but not in FF or Chrome. I am not fluent enough (yet) with javascript or firebug to figure out what is happening. The demo page can be found at:http://hooker.dotnetnebraska.com/index.php/gallery /* * Updates Photo Gallery */ function updateGallery() { $(.galleryNavHA).click(function(event){ event.preventDefault(); var href = this.href; var rel = this.rel; //$(.galleryMainImg).fadeOut(slow); $(.galleryMainImageDivCls).load(href); //$(.galleryMainImg).fadeIn(slow); $(.galleryNavDivCls).load(rel); return false; }); } Any help getting this to work would be greatly appreciated. Thanks, R Morgan -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Re: ajax.load(url) working in IE only
Ok James, just one question though. I am using CI-CMS and I have my gallery page is contained in a wrapper used for every page on the site. So if I add the binding in the page head (which is shared for all pages) the gallery classes tags do not exist. Will this cause an issue. If it does then I need to modify the js in the head when building up the gallery page contents. Again, I thank you for your help. I'm an old C/C++/Pascal /ADA/Fortran guy so I am not well versed in javascript or ajax. My code was mostly taken from some early ajax/php books. But I am eager to learn the proper ways of doing ajax and using jquery. It seems to have some amazing functionality built into it. Thanks again, Randall On Thu, Mar 12, 2009 at 2:46 PM, James james.gp@gmail.com wrote: The issue is not the anchor tag around the image. The issue is how your events and actions are working. This is what your script is doing: - A user clicks on the image (the a link) - This call updateGallery() - updateGallery() sets an event - when clicking on any a link with class galleryNavHA, you do the AJAX - End This doesn't actually do the AJAX. It just binds a click event. Suppose a user clicks on that (or any) image again: - User clicks on the image - This calls updateGallery() AND the binded event to do the AJAX. - updateGallery() sets another, duplicated, event - when clicking on any a link with class galleryNavHA, you do the AJAX - End What you need to do is bind the click event on page load. If the user has no Javascript enabled, the click binding will not be done, and the a link will do its default job. script $(function() { $(.galleryNavHA).click(function(event){ var href = this.href; var rel = this.rel; // do your ajax stuff return false; }); }); /script a class=galleryNavHA rel=http://hooker.dotnetnebraska.com/ index.php/gallery/getAjaxNavH/4/101 href=http:// hooker.dotnetnebraska.com/index.php/gallery/getAjaxMainImage/4/101 img class=galleryNavHImg src=http://hooker.dotnetnebraska.com/ images/o/30big.jpg //a This keeps the Javascript outside of the HTML also. On Mar 12, 11:18 am, Randall Morgan rmorga...@gmail.com wrote: Hi Yes, I have the anchors because I need to insure there is some functionality when js is not available. I have used anchors with my own ajax code without issue as long as I return false from the js function call. Is this a known issue with JQuery, that you can't provide a default action for an anchor? If it is, how to I insure the image is still available if javascript is turned off? Thank you for you help. On Thu, Mar 12, 2009 at 1:50 PM, mkmanning michaell...@gmail.com wrote: Not looking any further, you have anchors with inline onclick events (not considered good practice btw) which call the updateGallery() function, which then binds a click event on the same anchors, every time you click them again? a onclick=javascript:updateGallery(); class=galleryNavHA... You might want to rethink it a little bit :P On Mar 12, 10:46 am, Monotoba rmorga...@gmail.com wrote: Hello, I have use ajax.load in the following function to load both a main image and an image navigation bar on a single page. The fucntion works in IE but not in FF or Chrome. I am not fluent enough (yet) with javascript or firebug to figure out what is happening. The demo page can be found at:http://hooker.dotnetnebraska.com/index.php/gallery /* * Updates Photo Gallery */ function updateGallery() { $(.galleryNavHA).click(function(event){ event.preventDefault(); var href = this.href; var rel = this.rel; //$(.galleryMainImg).fadeOut(slow); $(.galleryMainImageDivCls).load(href); //$(.galleryMainImg).fadeIn(slow); $(.galleryNavDivCls).load(rel); return false; }); } Any help getting this to work would be greatly appreciated. Thanks, R Morgan -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take? -- If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?
[jQuery] Re: ajax.load(url) working in IE only
Thank you James. Coming form languages like C/C++ if I were to make a call to a non-existent method, you would see errors. So I sorta expected the same thing here. I guess I have a lot to learn yet. But with the help of good people like you I'll get there. Thank you again for you help. I will now make the changes to my code and see what happens. Sincerely, Randall On Thu, Mar 12, 2009 at 3:25 PM, James james.gp@gmail.com wrote: If you don't have any other classes galleryNavHA in your code nothing will happen. Though it might be very minor overhead since jQuery will try to do a check for it to bind the event. Just make sure you don't use the class elsewhere or else it might cause unexpected things to happen. If you have to use the code on several pages of your website might as well have it on all your pages. It's also okay if you don't put the script in your HEAD and put it in your BODY. It'll still run fine, but it is mixing Javascript with HTML, which isn't good practice. It's all up to you how you want to do it. On Mar 12, 12:03 pm, Randall Morgan rmorga...@gmail.com wrote: Ok James, just one question though. I am using CI-CMS and I have my gallery page is contained in a wrapper used for every page on the site. So if I add the binding in the page head (which is shared for all pages) the gallery classes tags do not exist. Will this cause an issue. If it does then I need to modify the js in the head when building up the gallery page contents. Again, I thank you for your help. I'm an old C/C++/Pascal /ADA/Fortran guy so I am not well versed in javascript or ajax. My code was mostly taken from some early ajax/php books. But I am eager to learn the proper ways of doing ajax and using jquery. It seems to have some amazing functionality built into it. Thanks again, Randall On Thu, Mar 12, 2009 at 2:46 PM, James james.gp@gmail.com wrote: The issue is not the anchor tag around the image. The issue is how your events and actions are working. This is what your script is doing: - A user clicks on the image (the a link) - This call updateGallery() - updateGallery() sets an event - when clicking on any a link with class galleryNavHA, you do the AJAX - End This doesn't actually do the AJAX. It just binds a click event. Suppose a user clicks on that (or any) image again: - User clicks on the image - This calls updateGallery() AND the binded event to do the AJAX. - updateGallery() sets another, duplicated, event - when clicking on any a link with class galleryNavHA, you do the AJAX - End What you need to do is bind the click event on page load. If the user has no Javascript enabled, the click binding will not be done, and the a link will do its default job. script $(function() { $(.galleryNavHA).click(function(event){ var href = this.href; var rel = this.rel; // do your ajax stuff return false; }); }); /script a class=galleryNavHA rel=http://hooker.dotnetnebraska.com/ index.php/gallery/getAjaxNavH/4/101 href=http:// hooker.dotnetnebraska.com/index.php/gallery/getAjaxMainImage/4/101 img class=galleryNavHImg src=http://hooker.dotnetnebraska.com/ images/o/30big.jpg //a This keeps the Javascript outside of the HTML also. On Mar 12, 11:18 am, Randall Morgan rmorga...@gmail.com wrote: Hi Yes, I have the anchors because I need to insure there is some functionality when js is not available. I have used anchors with my own ajax code without issue as long as I return false from the js function call. Is this a known issue with JQuery, that you can't provide a default action for an anchor? If it is, how to I insure the image is still available if javascript is turned off? Thank you for you help. On Thu, Mar 12, 2009 at 1:50 PM, mkmanning michaell...@gmail.com wrote: Not looking any further, you have anchors with inline onclick events (not considered good practice btw) which call the updateGallery() function, which then binds a click event on the same anchors, every time you click them again? a onclick=javascript:updateGallery(); class=galleryNavHA... You might want to rethink it a little bit :P On Mar 12, 10:46 am, Monotoba rmorga...@gmail.com wrote: Hello, I have use ajax.load in the following function to load both a main image and an image navigation bar on a single page. The fucntion works in IE but not in FF or Chrome. I am not fluent enough (yet) with javascript or firebug to figure out what is happening. The demo page can be found at: http://hooker.dotnetnebraska.com/index.php/gallery /* * Updates Photo Gallery */ function updateGallery