Question

my code is like this:

function EditData(){
        //$.messager.progress();    // display the progress bar
        $('#ff2').form('submit', {
            type: "Put",
            contentType: "text/html",
            dataType: "text/html",
            accept: "text/plain; charset=utf-8",
            onSubmit: function () {
                var isValid = $(this).form('validate');
                if (!isValid) {
                    $.messager.progress('close');   // hide progress bar while the form is invalid
                }
                return isValid; // return false will stop the form submission
            },
            success: function (data) {
                alert(data);
                //data = $.parseJSON(data);
                if (data.state == "success") {
                    $.messager.alert('Success', 'Success');
                    CloseWindow('w2');
                } else {
                    $.messager.alert('Failed', 'Failed');
                }

                $.messager.progress('close');   // hide progress bar while submit successfully
            }
        });
        //$('#ff2').submit();
    }

through Firefox, the returned data is :

{"state":"success","message":"1","sql":"**"}

however,when I used like this:

alert(data.state);

Firefox pop like this:

<div id="json">{<ul class="obj collapsible"><li><span class="prop"><span class="q">"</span>state<span class="q">"</span></span>: <span class="string">"success"</span>,</li><li><span class="prop"><span class="q">"</span>message<span class="q">"</span></span>: <span class="string">"1"</span>,</li><li><span class="prop"><span class="q">"</span>sql<span class="q">"</span></span>: <span class="string">"**"</span></li></ul>}</div>

Can anyone help me?

Was it helpful?

Solution

You can forbidden the jsonview of firefox.

the returned data like this:

   data=eval("("+data+")");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top