Results 1 to 6 of 6

Thread: how to crete nested json for ajax call in extjs

  1. #1

    Default how to crete nested json for ajax call in extjs

    i want to create this param filed so that i can send it to my web service




    var parms={
    "quiz_id":"120","owner_id":"1","solver_id":"1",
    "answers":
    [
    {
    "answer_text" : "YES",
    "question_id" : "1"
    },
    {
    "answer_text" : "NO",
    "question_id" : "2"
    },
    {
    "answer_text" : "YES",
    "question_id" : "3"
    },
    {
    "answer_text" : "YES",
    "question_id" : "4"
    },
    {
    "answer_text" : "YES",
    "question_id" : "5"
    }
    ]
    };


    i am stuck with the contnets inside the answers i dont know how to create it dynamically .

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    That depends on your UI
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3

    Default

    means... can u please help me

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379

    Default

    Means it is impossible to know for sure how to build an object like that without knowing what your UI looks like. Do you have form fields? Iterate through them and create an object for each field and push to the array.
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  5. #5

    Default

    quiz1.jpg
    Attached Images Attached Images
    Last edited by abdulshkh9; 13 Mar 2012 at 8:57 PM. Reason: image is to small

  6. #6

    Default

    this is a quiz, user answer and i want to create nested json and give this answer to webservice .
    question may be 5 and 10 so i want to create json based on question whether it is 5 or 10.
    This my code i am temporarily using static json
    function SubmitQuizAnswere()
    {

    var uid=1; //passing the user id to the function
    var rid=2; //passing the reciver is to th function
    var parms={
    "quiz_id":"120","owner_id":"1","solver_id":"1",
    "answers":
    [
    {
    "answer_text" : "YES",
    "question_id" : "1"
    },
    {
    "answer_text" : "NO",
    "question_id" : "2"
    },
    {
    "answer_text" : "YES",
    "question_id" : "3"
    },
    {
    "answer_text" : "YES",
    "question_id" : "4"
    },
    {
    "answer_text" : "YES",
    "question_id" : "5"
    }
    ]
    };
    //params: { foo: 'bar' }
    Ext.Ajax.request({
    url: 'webservice call',
    params:Ext.encode(parms),

    headers:{'Content-type': 'application/json;charset=utf-8'},
    success: function (result,request)

    {
    retData = (result.responseText);
    //alert(retData);
    retData = eval("(" + retData + ")");

    if (retData.status == "success")
    {
    document.getElementById('QuizDivPopup').style.display ='none';
    alert(retData.message);


    }
    },
    failure:function (result,request)
    {
    alert(result.statusText);
    }

    });

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •