-1

I have tried to call a method/function with parameter from list, But its neither pasing nor calling method.Here my code. Here is my code

LIST

var searchfrieandtab=  Ext.create('Ext.List', {
    width: 320,
    height: 290,
    id : 'searchfriendslist1',
    itemTpl: ['<div style="margin:0px;background:#fff;" >'+
              '<table style="margin:0px;padding:0px;height:40px;" width="100%" >'+
              '<tr><td style="padding:2px 5px;width:90%;"><span><img src="data:image/jpeg;base64,{userImage}"/>'+
              '</span><span>{userFirstName}</span></td>'+
              '<td style="padding:2px 10px;width:10%;">'+
              '<img src="resources/img/addplus.png" onclick="invitefriends{\'{userId}\')"/>'+//HERE AM CALLING THE METHOD
              '</td></tr></table></div>'].join(),
    listeners : {
        itemtap: function (list, index, item, record, senchaEvent) {
            if (senchaEvent.event.target.nodeName == 'IMG') {
                var data = record.getData();
                var itemId = data.itemId;
                var itemPurchased = data.itemPurchased;
            }
         }
     }
});

METHOD

function invitefriends(friendid) {
 alert("check",friendid);

 Ext.Ajax.request({
    //url: App.gvars.apiurl + 'InviteFriends/userID='+App.gvars.userid+'/friendID='+friendid, // url : this.getUrl(),
    url:'http://192.168.1.155:8181/WishList/InviteFriends/userID=1/friendID='+friendid,
    method: "GET",
    useDefaultXhrHeader: false,
    withCredentials: true,
    success: function (response) {
          var respObj = Ext.JSON.decode(response.responseText);
    if(respObj[0].response=="Success"){
        alert(Response)
        Ext.Msg.alert("Invite Friends",respObj[0].MailResponse);
    }else{
       Ext.Msg.alert("Error",respObj[0].errorMsg);
    }

    },
    failure: function (response) {
        Ext.Msg.alert("Error",response.responseText);
    }

});

}

Whats wrong with my code?Please help me to solve

4

2 に答える 2

2

この作品は間違っていinvitefriends{\'ます。「{」は「(」にする必要があります。

あなたのコードはここで変に見え"errorMsg": "".ます 成功メソッドで変数を宣言しようとしていますか? 使用されていないことがわかりますが、これらの行 (「errorMsg」と「MailResponse」) を削除してください。

最初にこれらのようなエラーについてコードをチェックしていないため、この質問に反対票を投じています。

于 2013-09-04T06:30:24.757 に答える