I plan to create an object in a javascript file, and then use that object and it's methods on both the server and the client side. Assume an ASP file with the code 'var product = new Product();'
The following declaration in the javascript file works fine:
This declaration, however, produces a runtime error 'Object Expected' on the line creating the new product.
Simplifying the issue, I found that if I simply declared a string with 'var text = "hello world!";', and then called 'Response.Write(String(text));' in my asp page, it returns 'undefined'. However, if I remove the variable declaration from the javascript file, it returns a runtime error: 'text' is undefined.
Can anyone explain this behaviour and provide a solution?
The following declaration in the javascript file works fine:
Code:
function Product () {}
function Product.prototype.addToCart() {}
This declaration, however, produces a runtime error 'Object Expected' on the line creating the new product.
Code:
var Product = function() {}
Product.prototype.addToCart() {}
Simplifying the issue, I found that if I simply declared a string with 'var text = "hello world!";', and then called 'Response.Write(String(text));' in my asp page, it returns 'undefined'. However, if I remove the variable declaration from the javascript file, it returns a runtime error: 'text' is undefined.
Can anyone explain this behaviour and provide a solution?