View Full Version : PHP, Ajax, and JQuery

09-02-2010, 11:20 PM
so i have this "class" defined in a javascript file, "a.cross-link". This enables the ability for users to navigate the webpage in a slider format. it works fine if I directly place the required html code:

<a class="cross-link" href="#3" title="Go to Page 2">View Results</a>but if i have php print out that line for me, it doesn't work:

echo "<a class= \"cross-link\" href=\"#3\" title=\"Go to Page 3\">$name</a>";(Where $name is some variable)

Note: the php code is just your average sql stuff. here is an interesting observation i've made:

if i "hardcode" this this into the html: <a class="cross-link" href="#3" title="Go to Page 3">View Results</a>
and then i go to generate the sourcecode, this is what appears (this works): <A class=cross-link title="Go to Page 3" href="#3" jQuery1283131847233="30">View Results</A>

but if i have the html made by a php echo statement, it just stays the same - i dont get a jQuery1283131847233="30" generated in the sourcecode.

i'm sorry i'm having difficulty describing the problem. i'm new to jquery and ajax stuff. to me, it seems like the "cross-link" class i have defined in the javascript isn't being applied to correctly. i have no idea. can you invoke javascript from a php echo statement that is formatted to produce html code?

here is another thing i believe is true: when the page loads, the javascript loads. the users, through the use of ajax, submitts a sql querey and navigates, using a jquery slider, to another div (where i want the user to go after selecting a resulting link from the sql query). so the javascript is going to execute before the list of results is produced. do I need to rerun the javascript each time new php produced sql data is populated in a div? if so, how?

i dont know what more information you may need, so please ask. Thanks.

09-05-2010, 09:27 PM
here is an example of the problem (and how to produce it):

1) go to http://eataustineat.com/testfolder/index.php
2) type in an 'a' into the text field
3) click "view results"
4) select the first result (ie: Dog Almighty)

Notice the javascript slide doesn't happen. In fact, nothing appears to happen. It is suppose to slide the content to the left much like it did when you hit "view results".

I hope this clears the problem up some.