0

I am trying to submit a form using ajax and want to check to see if the correct values are sent. How do I do it using the following. Currently, it is sending it to a MVC controller, but I do not want to do that. Is there a way to just sent to the same view page and show all the values???

 $(document).ready(function () {
    $("#btnSubmit").click(sendValues);
});

function sendValues() {
    var a = store.data.items;
    var array = new Array();
    for (var i = 0; i < store.data.items.length; i++) {
        array[i] = store.data.items[i].data;
    }
    for (var i = 0; i < array.length; i++) {
        if (array[i].value == "Using") {
            array[i].value = true;
        }
        else {
            array[i].value = false;
        }
    }
    var ClintJSON =
    {
        "Exempt": Ext.getCmp("mmrComboBox").isIndexSelected(2),
        "MM1": Ext.getCmp("mmrComboBox").isIndexSelected(3),
        "MM2": Ext.getCmp("mmrComboBox").isIndexSelected(4),
        "MM3": Ext.getCmp("mmrComboBox").isIndexSelected(5),
        "B1": Ext.getCmp("BComboBox").isIndexSelected(2),
        "B2": Ext.getCmp("BComboBox").isIndexSelected(3),
        "B3": Ext.getCmp("BComboBox").isIndexSelected(4)                    

    };

    $.ajax({
        jsonp: null,
        jsonpCallback: null,
        type: 'POST',
        url: '@Url.Content("~/Site/Test")',
        data: "{clinsite: " + Ext.util.JSON.encode(ClintJSON) + ", List: " +      `    
         Ext.util.JSON.encode(array) + "}",
        dataType: 'json'
        , contentType: 'application/json; charset=utf-8'
        , success: function (data) {
            if (data.success) {
                showMessage('Site requirements have been updated successfully');
                store.load({ params: { start: 0, limit: 52} });
            } else {
                showMessage('Site requirements have NOT been updated!!! ');
                store.load({ params: { start: 0, limit: 50} });
            }
        }
    });
0

2 Answers 2

1

There is one tool that I cannot recommend enough in this type of scenario, Fiddler2.

You can download it here

It enabled you to examine exactly what is passed to and from the server and you can view the data in various formats i.e. json, web form data or plain old text.

You can also use Composer to simulate http requests, which has its obvious benefits.

As a profession web applications developer, I use this tool all day every day, like I said I can't recommend it enough!!

Cheers

Baz

Sign up to request clarification or add additional context in comments.

Comments

0

you can inspect the values in firefox using firebug console or in chrome tools, just press f12 and a window will open infront of your

moreover you can log the ClientJaon to the console liek

console.log(ClintJSON );

2 Comments

how do you use console.log(ClintJSON) in chrome(f12)? do you include this line in the javascript code like the following: $(document).ready(function () { $("#btnSubmit").click(sendValues); console.log(ClintJSON ); }); or do you type it into the F12 Console Screen? > console.log(ClintJSON )
You write console.log in your javascript code and this is output to the console screen in F12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.