Jump to content

neuroxik

Members
  • Posts

    43
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

neuroxik's Achievements

Member

Member (2/5)

0

Reputation

  1. Hooo! It works now! Thank you so much for all your time!
  2. Sorry for replying late again, pretty busy week + sick but I really appreciate your help and input. I thought it might be the regex. I did use the as different trailing ID numbers as quoted in my previous post. I'll try the alert and put it on my server so you can see by the source, if ever you have the time that is. My test of the previous example can be seen here : http://arraykey.com/ajaxtests/test9.php . The reason the second link makes it jump a line is because the strings I fetch are embedded in <p></p> tags, so that's what's creating the break-line (not an issue, I was just mentioning in case you were wondering) And here's with alert(divID) as you suggested : http://arraykey.com/ajaxtests/test10.php
  3. Hmm, it halfway works, but I see where you're getting at, great idea. Thanks! I'm not trying you to solve it, I'll only explain what happens in case you were wondering : <a href="ajaxtest.php?data=1" class="reload tDiv" id="tDiv1">Click Here 1</a> <!-- yeh, I had them named as tDiv by now, but same principle as you --> <a href="ajaxtest.php?data=2" class="reload tDiv" id="tDiv2">Click Here 2</a> <div id="tDiv"><!-- load here --></div> What this does (with your functions) is the first link (Click Here 1) loads the data correctly in tDiv, but link 2 loads it, somehow, where "Click here 2" itself was. At first I thought the data was only appending itself until I saw the 2nd link itself dissapear. Again, no big deal, I'm trying to figure this out myself. I suck at Javascript to be honest, but I think that's clearly been made obvious. Thanks again for your input! Great insights.
  4. Thanks! Now that works. Yes, should've checked the console. By the way, speaking of consoles, I use ConsoleĀ² and Firebug for Firefox, would you have any better suggestions? A huge thank you to Xaotique and you, DavidAM, for having shed alot of light on this. I'll still try to manage passing the target Div through argument (maybe through the "rel" attribute? I was worried about semantics but again, it is sort of "related" if you take it into context). Atleast now I have some working ground to do this by myself, I just didn't know where to start, so a huge thank you again! {marking as solved}
  5. Ah, I can't edit my last post anymore, sorry for bumping. Tried the above code and doesn't work, it loads the page like a href normally would do.
  6. Sorry, I've been really sick for the last couple of days and wasn't able to get back to you. So I've just tested changing the load(url) to html(data) (I had actually tried load(data) as last resort the other day, which obvisouly didn't work either) and now this seems to work so far. Thank you! I'll post the code below as requested, only difference is the other day html(data) was load(url). There's not much, I only did test files apart without any sanitization because they're only tests : test4.php : <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> </style> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".myClass").click(function(e) { e.preventDefault(); $.get($(this).attr("href"), function(data) { $("#myDivID").html(data); /* chg'ed "load(url)" to "html(data)" */ }); return false; }); }); </script> </head> <body> <a href="ajaxtest.php?data=1" class="myClass">Click Here 1</a> <a href="ajaxtest.php?data=2" class="myClass">Click Here 2</a> <div id="myDivID"><!-- load here --></div> </body> </html> and ajaxtest.php : <?php $data = addslashes($_GET['data']); if($data) { if($data=='1') echo '<p>some data one</p>'; elseif($data=='2') echo '<h1>other data two</h1>'; } ?> I'll just try to re-put some code you had suggested earlier so that some instances can have some content load by default on page load. EDIT: I'm still trying to figure out how I could pass the target ID within the link so I can use different links (in other sections of the page) that would load in other divs rather than load them in #myDivID. Of couse, I wouldn't name those links with the "myClass" class, but would I have to create a different function for each case or can I just pass the target div (div to load content in) as an argument rather than hardcode it as #myDivID ?
  7. Yeah, I'm sorry about the class, I know you mentioned it now but I was so overwhelmed by the Javascript that I thought you meant writing a class as in OOP class. Wow! This worked! But when I changed alert(data) to $("#myDivID").load(url); it doesn't load, I don't know what I'm doing wrong there. I did obviously include the div itself with #myDivID. By the way, a huge thanks, I know this must seem like trivial stuff for you guys but it's helping me out alot.
  8. Hm, great idea. Unfortunately it doesn't load anything. Atleast it solves the double ID and the 2nd link loading a new page doesn't do that anymore. Thanks nonetheless for having taken the time to check out my problem!
  9. Thanks for you reply again! I tried this like you said: $("#myLinkID").click(function(e) { var url = $(this).attr("href"); /* <-- added var url THIS */ e.preventDefault(); $("#myDivID").load(url); return false; }); /* and for test links : */ <div id="bla">links : <a href="ajaxtest.php?action=no&data=1" id="myLinkID">1</a> <a href="ajaxtest.php?action=no&data=2" id="myLinkID">2</a> </div> <div id="myDivID"><!-- load here --></div> It works on the first click (thanks!) but doesn't when say I click on link 2, it loads the called (href) page instead of loading it in the div. I'm presuming because both links share the same Div ID. Anyway, thanks alot for your input, I'll try figuring out from here on, atleast I have some base to work on.
  10. Thanks for the reply! I read and tested the code and the first ones loaded the content into the div on page load. I'm not looking to autoload content but rather load the content when the user clicks. The last part of your code did actually work for that, this part: $("#myLinkID").click(function(e) { e.preventDefault(); $("#myDivID").load(url); return false; }); Now two things as I've mentioned earlier : 1 - Can I put the url part (the one that in your code is declared as var url) in the link? I want this because my links are change depending on the context and get the context via GET variables, so I can have (in this case a calendar) "cal.php?sel_year=2013&sel_month=04". I'm trying to figure out how to pass the url string as an argument. 2 - I'll be using this on multiple links on multiple divs for different purposes. Do I have to write a function for each target div or can I (most logically) pass the Div ID as an argument too?
  11. I've searched everywhere and just can't seem to find my answer, so here: I'm powerful with php and that I can deal with, but I never really had the chance to develop my javascript skills. I want to use JQuery to load part of a page in a container div. The problem is every tutorial I check out, the target (or result) div where the content will load is already defined in the function. Is there a way to include 2 arguments like this : (pseudo-code, I don't know the real syntax, still a newb at JQuery) function ajaxpage(url, containerid){ // do the magic here } // and calling the page <a href="javascriptTheJQueryWayHere:ajaxpage('page.php?id=12','load_in_this_div')">link</a> <div id="load_in_this_div"></div> I don't necessarily want a baked answer, just any link to any resource except RTFM would be of great help!
  12. Thanks! I was hoping this was not the case but now atleast I know. I was going to check my browser cache to see but then again, doesn't mean it's not cached that it hasn't been downloaded.
  13. Hey everyone, I've been starting to use @font-face in the last year or so seeing that most major browsers support it now. I usually just use 1-3 fonts max, but most often I include the italics version, bold and italic bold version, which can easily amount to a couple MBs of data minimum (depending on the font). Since I use EOT, TTF, WOFF and SVG to work in most browsers, the filesize augments. I don't want too much bandwidth (and load time) used, especially when it's not absolutely necessary upon the customer's request, so I was wondering : say if Firefox (or any browser) successfully loads the EOT version of the file, will that browser still download all 3 others or it will specifically ignore the rest? If it does ignore the rest (not download them) then bandwidth would be much less of an issue. I know some of you might say "well, bandwidth nowadays...", but I still prefer to keep things minimal by habit.
  14. I'm pretty much out for the rest of the week but I'll try that out some time soon and let you know if I come across a problem or come and praise you if this works. Thanks alot. I hate having overkilled on the code because I ignored about metaphone and the similar functions, but hey, we're always learning.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.