Use
JSHint or a similar lint tool, it shows you issues with your code.
Let’s format your code a little better so it’s easier to read:
PHP Code:
$('#productsdiv').append(
$('<li></li>').append(
$('<p></p>')
.text(val.productname)
.hover(
function () {$(this).addClass('hover');},
function () {$(this).removeClass('hover');}
)
.on("click", {
prodcode: prodcode,
sellerid: sellerid,
ordernum: ordernum
}, salesorder); // end on()
) // end append()
) // end append()
It’s hard to spot but actually quite logical: The semicolon after
salesorder) is wrong as it’s inside the
append() function.
However, you could have saved all that hassle if you wrote your code a little more effectively:
PHP Code:
$('#productsdiv').append(
$('<li>').append(
$('<p>', {
text: val.productname,
hover: function() {$(this).toggleClass('hover');},
click: function() {
// do stuff on click
}
}) // end <p>
) // end append()
) // end append()