sambit.albus
sambit.albus

Reputation: 250

Cross domain Ajax call In Blackberry Webworks Error Bad Request

I'm very new to blackberry webworks. When I'm writing a jQuery ajax request to a Asp.net webservice which accepts two value. It returns Error Bad request. I'm using ripple for Chrome plugin for testing. The code is

  jQuery.support.cors = true;
$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "http://xyz.in/webservice.asmx/backup_p",
    data: "{ 'id': '1', 'data': '4' }",

    dataType: "json",
    success: function (msg) {
        alert('sucess !!!');
        alert(msg.d);


    },
    error: function (jqXHR, textStatus, errorThrown) {
        alert('hello');

        alert(jqXHR + " : " + textStatus + " : " + errorThrown);
    }
});

I tried many methods but without any solution. It is something to do with ripple?

Upvotes: 0

Views: 391

Answers (1)

Musa
Musa

Reputation: 97717

Your json is invalid, it should be { "id": "1", "data": "4" }, notice how the key and string quotes are " instead of '.
Also instead of building ajax by hand use JSON.stringify. e.g.

data: JSON.stringify({ 'id': '1', 'data': '4' }),

Upvotes: 1

Related Questions