0

image1: enter image description here

image2: enter image description here

image3: enter image description here

Question number one: Is it possible thing to make an angularJS form into an ajax json variable request? note: I'm using it because of it's pattern, just for validation rule of form. It's very simple and taft, i like it.

Question number two: If this way doesn't worked, is there any other security way as simplest as like this angularJS system which can be done inside an ajax like this?

this is my simple ajax code:

var x;
function clickreply(obj){
    var varid = obj.id;
    var getnumb = varid.match(/\d/g); //get number from string
    var idreply = 'idreply'+getnumb;
    console.log(varid);
    console.log(getnumb);
    console.log(idreply);
    $.ajax({
        url: '/logincheckmember2.php', //This is the current doc
        type: "POST",
        dataType:'json', // add json datatype to get json
        success : 
        function (result) {
            x=result['ssloginmember'];
            console.log(x);
            if(result['ssloginmember']==null){
                msgBLshow();
            }else{
                x="<center>"+
                    "<form method='post' ng-controller='formctrl' name='myForm'>"+
                        "<textarea id='tareply' rows='4' cols='50' maxlength='250' placeholder='maxlength=250' ng-model='tareply' required ng-pattern='/^[A-Za-z0-9/\.\-\s\,]*$/'></textarea><br>"+
                        "<span ng-show='myForm.tareply.$error.pattern' ng-cloak><img src='/img/xred.png'></img> <font color='red'>invalid value</font></span><br>"+
                        "<input type='button' value='reply' onclick='clicktareply()' ></input>"+
                    "</<form>"+
                "</center>";
                document.getElementById("msgcontent1").innerHTML=x;
                $("#msg1").fadeTo(1000, 1);
            }                   
        }
    });
}
function clicktareply(){
    alert(document.getElementById("tareply").value);
}
Juna serbaserbi
  • 205
  • 2
  • 12
  • Looks like you are coming from jQuery to AngularJs. In that case these links might help you http://tech.zumba.com/2014/08/02/angularjs-forget-jquery/ and http://stackoverflow.com/questions/14994391/thinking-in-angularjs-if-i-have-a-jquery-background. In short: You should use directives with templates instead of inserting magic html string into DOM – David Votrubec Nov 09 '15 at 10:56
  • i saw the words "Angular and jQuery do different things", ok i understand right now. Thank you David. – Juna serbaserbi Nov 09 '15 at 11:37

0 Answers0