2

[RE-EDIT] I am trying to pass a value to the server and read from the server using JSONP. I have been able to implement this code:

var record = new Object();  

     record["deviceID"] = "123"; 
     options = {

          url: "http://192.168.2.143:8080/commapi/comaction/init?callback=?",

          type: "POST",

          data: {dataset: JSON.stringify(record) },
              jsonp: "callback",

          dataType: "jsonp",
              callbackParameter: "jsoncallback",

          success: function(result) {

              alert(result["retdic.deviceID"]);

          },
              error: function(XHR, textStatus, errorThrown){
              alert("ERROR: " + textStatus);
              alert("ERROR: " + errorThrown);
        }
           };
          jQuery.ajax(options);   

});

However I receive an invalid label error from FireFox firebug. Could anyone please let me know what it is I am doing wrong? A few examples would be great;y appreciated.

Thanks.

[RE-EDIT] The error produced is:

  invalid label
{"ret":"ACK","retdic":{"ak":"Bvr7/ljfj...X212yA+XJR5+AdrmE=","deviceID":"123"}}

The error returned is parseError. I am not sure where I am going wrong. Could anyone give me a hand, please?

Thanks.

user788511
  • 1,726
  • 2
  • 30
  • 52

2 Answers2

0

This could solve your problem:

Jquery getJSON to external PHP page

Just make sure your shared some server-side code, so that we know how the response should look like

Community
  • 1
  • 1
WooDzu
  • 4,771
  • 6
  • 31
  • 61
0

try this

 alert(result.retdic.deviceID);
Vikas Naranje
  • 2,350
  • 5
  • 30
  • 40
  • can you only try with this alert(JSON.stringify(result)); in your success callback. It will alert the all json data that success function has returned. also remove jsonp: "callback", and use dataType: "json", in your code. – Vikas Naranje Oct 25 '11 at 09:44
  • Thanks Vikas, but I still receive the invalid label error..am at wits end now..not sure what I'm doing wrong!! – user788511 Oct 25 '11 at 10:00