开发者

how to create live obect using jquery

There is Json array and i am using it to display my error messages.

var errorMe开发者_JS百科ssages {
"E1":"Error Occured During Request Processing...",  
"E2":" Enter User Name"
}

Next i want to display error messages base on error id

function showMessage(errorId){
    $('#serverMsg').html('');
    var msg = $('#messageContainer');        
    if (errorId.length != 0) {
            $('#messageContainer').show();
            $('#serverMsg').html(errorMessages.errorId);
    }   
    $("#messageContainer").focus(); 
}

it gives me undfine.


Perhaps you mean:

var errorMessages = {
  "E1": "Error Occured During Request Processing...",  
  "E2": " Enter User Name"
};

Also as Daniel said below make sure you realize that errorMessages doesn't have a property called errorId, if you want to use errorId to 'look up' the right message then you have to write it like:

errorMessages[errorId]


Instead of

$('#serverMsg').html(errorMessages.errorId);

try this

$('#serverMsg').html(errorMessages[errorId]);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜