Skip to content
Advertisement

Calling class method in jquery

Hey im trying to build a simple inventory program. I have class like this :

JavaScript

now i want to append rows in my table which contain select option like this:

JavaScript

but new row wont added if call my class using normal php line. It does however add a new row if i remove the php line. So, how can i call my class in jquery ?

Advertisement

Answer

The static PHP function is called, but the problem is that it returns a string with single quotes, which happens to be the string delimiter you use in JavaScript, and so the JS string literal terminates at a place you don’t want it to end. Also, you used the line continuation character at every line in the JS string literal, but not after the PHP-generated content, so that also would break the string literal.

The easiest solution is to use the back tick character in JS to delimit your string, so it becomes a template literal. This way you don’t need the line continuation character either.

So like this:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement