I am not sure about this code. This structure is correct?
success: function(data, data1, data3, .... ) {
switch (data.livre) {
case 'x':
break;
}
switch (data1.livre1) {
case 'y':
break;
}
开发者_开发百科 }
thanks
For future reference here is a code quality tool : jshint
The above is indeed "correct" code as in it will parse correctly. But it can be improved though.
success: function(data) {
if (data.livre === 'x') {
...
}
if (data.livre1 === 'y') {
...
}
}
Be wary that you generally pass one result back. So you should get the server to pass an object or array of data back.
The real question is, do you have a problem? and what are you trying to achieve?
I'm not sure which part of the function you're asking about, but maybe you mean either:
function success( ... ) { .... }
Or,
success = function( ... ) { .... }
Using success: function
doesn't make sense in isolation, but people are so used to reading that as a JS object property they might think its ok...
If that's inside of an object, sure. Looks right to me.
i.e.
var obj = {
success: function(...
};
精彩评论