开发者

how to create live obect using jquery

开发者 https://www.devze.com 2022-12-16 13:52 出处:网络
There is Json array and i am using it to display my error messages. var errorMe开发者_JS百科ssages {

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

精彩评论

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