Jump to content


Member Since 24 May 2006
Offline Last Active Apr 17 2013 04:09 PM

Posts I've Made

In Topic: JQuery load php in div INCLUDING arguments

17 April 2013 - 12:46 PM

Gees, I'm an idiot!

divID.replace(/[0-1]*$/, '')

That should be 0-9 (zero through nine) not 0-1. And the * should probably be a + (* means zero or more, + means one or more).

Sorry about that.

Hooo! It works now! Thank you so much for all your time!

In Topic: JQuery load php in div INCLUDING arguments

15 April 2013 - 09:12 PM

Sounds like the replace may not be working (or you left the "2" off the Anchor's ID). I don't do a lot of JS so the expression might not be write. Try an alert(DivID); right after this line
divID = '#' + divID.replace(/[0-1]*$/, ''); to see if it is working as expected (should show the DIV's ID).

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/...tests/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 :



In Topic: JQuery load php in div INCLUDING arguments

12 April 2013 - 06:45 PM

I usually just use what's now built-in to Firefox. But then, I don't do a lot of JS.

In reference to passing the DIV ID. You could set the Anchor ID to whatever the DIV ID is adding a trailing sequence number. Then something like this might work:<DIV id="reloadDogs"></DIV>

* Not tested

Then you could style all of the .reload links exactly the same using CSS.


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.

In Topic: JQuery load php in div INCLUDING arguments

12 April 2013 - 03:32 PM

It's a typo in the function definition. I forgot to close the parenthesis on the .get() function call. Man I really hate anonymous functions.

	function loadToDiv(psUrl, psDivSelect) {
		$.get(psUrl, function(data) {
[edit] If you watch the Conole, JavaScript should have reported an error when it loaded that script.


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}

In Topic: JQuery load php in div INCLUDING arguments

12 April 2013 - 09:26 AM

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.

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime