user2129623
user2129623

Reputation: 2257

Loading php file with ajax call and performing button click event

In my start.php I was calling few function on button click event.

This function was calling some other functions from .js file included in it.

Now I created new file login.php. On this when user perform successful login I load start.php through ajax call.

But now when I click button it says :

Uncaught TypeError: Object [object Object] has no method 'rateit'

Though I have included .js files and functions in login.php.

Here is the link to both of them:

login.php - https://gist.github.com/karimkhanp/74b81267c4ae870dd432

start.php - https://gist.github.com/karimkhanp/94a601d5bf9f5bb2dee0

Upvotes: 0

Views: 482

Answers (1)

Steve Valliere
Steve Valliere

Reputation: 1892

When the login page loads it can't bind the functions you are creating for the start page to the elements that don't yet exist. For instance the element #rateit99 can't be used in the script in login.php because it doesn't exist when that page loads.

You need to move the script part that relates to the start.php back into that php file. This way when it loads start.php through ajax it will bind the functions correctly.

Upvotes: 1

Related Questions