Reputation: 393
I have an ajax loaded content where i want to use a php script.
The problem is that the script doesn't work and if i try to .load
it inside the ajax
loaded content it gives an error stating "$ is not defined"
.
Is there a way to load a php script inside a dinamically loaded content?
Thanks
edit: i solved the $ is not defiend thing. ok, some clarifiations. These are the steps: INDEX->menu click->ajax loads html into a div inside INDEX->inside that html i put a .load that should load the output of a php script. Unfortunately it doesn't work.
edit2: i was just stupid, the php script did load just well, the problem was i missed a character in the password for the db and it didn't load the content. Thanks
Upvotes: 0
Views: 327
Reputation: 2011
Check jquery library is loaded properly or not? as well as check your jquery must not conflict with other jquery so use jQuery.noConflcit();
to avoid error.
Upvotes: 0
Reputation: 31033
"$ is not defined"
means the jquery library is not loaded check that
you have provided the correct path to the jQuery.js file, also include the jquery before including any other js
library
try using a cdn hosted version of jquery
EDIT
when you bind events to the dynamically loaded elements you have to use .on
(jquery 1.7+) or .delegate
like
$(document).delegate( "yourElement", "load",
function(e) {
alert("loaded");
});
Upvotes: 2
Reputation: 13374
Check whether the jquery package is included before your script and that should not redefined any where before your script like jquery.noConflict().
Upvotes: 0
Reputation: 7277
No, you cannot load a PHP script and run it in the browser. If you setup your server to run the PHP script, you can load the output of the PHP script in your browser using AJAX.
Upvotes: 1