0

I have got one app running on two servers, one works and one doesnt cant understand why.

ajax query..

 $.ajax({
        type: "POST",
        url: "WebService.asmx/GetFinish1",
        data: '{' +
                        'Item:"' + item + '"' +
                   '}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (msg) {
            var data = jQuery.parseJSON(msg);
            $("#item").val(JSON.stringify(msg));

at line $("#item").val(JSON.stringify(msg)); from one i get...

{"d":"{\"0\":{\"i\":\"MODIFIED C/W TOOL MC WALL\",\"D\":\"Notes\",\"V\":\"MODIFIED C/W TOOL MC WALL\"},\"1\":{\"i\":\"EA\",\"D\":\"Unit\",\"V\":\"EA\"},\"2\":{\"i\":\"EA\",\"D\":\"Unit\",\"De\":\"Unit\",\"V\":\"EA\"}}"}

the second i get

"{\"0\":{\"i\":\"1x 8351-3  &  2 x 8352-3\",\"D\":\"Notes\",\"V\":\"1x 8351-3  &  2 x 8352-3\"},\"1\":{\"i\":\"PC3\",\"D\":\"Unit\",\"V\":\"PC3\"},\"2\":{\"i\":\"PC3\",\"D\":\"Unit\",\"De\":\"Unit\",\"V\":\"PC3\"}}"

the second one works, the first doesnt, but why the difference? same code! where does the extra {} and d: come from?

1
  • Are you positive both servers are running the same code? Commented May 28, 2012 at 14:49

2 Answers 2

1

You don't need

var data = jQuery.parseJSON(msg);
$("#item").val(JSON.stringify(msg));

Because, msg is already JSON formatted due to dataType: 'json' used in ajax property.

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

Comments

0

I don't know why, but I had to use the following var data = jQuery.parseJSON(msg.d);

Comments

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.