Page 1 of 2

AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 2:43 pm
by Alfred Butler

I have been battling this issue with a AJAX call. And from what i can determine via
the internet is that the parse from jquery is not working.

Don't know.

I do know these items:

  1. my JSON data going out is good.

  2. I have tested my server correctly by running all my REST tests.

  3. The server does not get the network request using my JavaScript AJAX call.

  4. If i remember correctly, I did at one time use the appery.io service set up and got a successful network call. I think I did.

    Then i switched to my "roll your own" AJAX calls.

    There seems to be some posts that say the jquery V1.8+ needs jquery.validate.js as opposed to using jquery.validate.min.js.

    So questions.

  5. I wouldn't mind using appery.io AJAX api, if you got one. You got docs?
    I need control of data being formed as well as the response.

  6. If indeed yours works, and i want to roll my own....what is my responsibility in doing this? Do I need to locate some jquery libs and replace them?
    This could be very tedious, especially after downloading the code and testing.

    Oh and i am working out of Android downloaded code and running inside of Android Studio from JetBrains.

    Regards Al


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 3:14 pm
by maxkatz

How did you define the Ajax request? Did you set up a REST service in Appery.io?


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 5:52 pm
by Alfred Butler

i did set a appery service once. But got confused on the return data and how to access it. So I rolled my own.

Like i said, the server doesn't break at all so apparently the ajax is parsing the data BEFORE it goes out. And then I stumbled on the internet comments about jquery parsing.

Here is a snippet:

var request = {
url: uri,
type: method,
contentType: "application/json; charset=UTF-8",
accepts: "application/json",
cache: false,
async:false,
dataType: 'text json',
//data: JSON.stringify(data),
data: {query: json_data_out},
//processData:false,
//traditional:true,
beforeSend: function (xhr) {
//xhr.setRequestHeader("Authorization",
// "Basic " + btoa(self.username + ":" + self.password));
},
error: function(jqXHR,status,errorThrown) {
//console.log("ajax error " + jqXHR.status);
alert("error: ajax status " + jqXHR.status);
alert("error: ajax errorThrown " + errorThrown);
//alert("error: ajax response Text " + jqXHR.responseText);

Code: Select all

             } 
         }; 
         return $.ajax(request); 

I will be glad to use your service.js set up but need some guidance on how to trap for the data so I can do what i need to.

Thanks Al


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 5:55 pm
by maxkatz

We can help if you want to define the service via Appery.io service editor. I hope you understand, but doing it directly with JavaScript is outside the scope of our support.


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 6:12 pm
by Alfred Butler

Alright. I'll go back and set it up.
Probably over the weekend.

Thanks Al


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 6:39 pm
by Alfred Butler

I am stuck in your service interface.

I am trying to describe this JSON data. (The request)

How you do this in the interface

{
"amount" : "12.00",
"account":
{
"siteuser" : "1774323232",
"password" : "1007232323",
"clientversion" : "1.0",
"sendtextmessage" : "true",
"language" : "en",
"appname" : "Android;OS4.2",
"immediate" : "true",
"product" : "1"
}

}

If amount is one parameter
Then the Account is a "add level" ???
And after that I then add all of those parameters

it's a PUT but i don't that matters


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 6:53 pm
by Maryna Brodina

Hello! Yes, you have two parameters "amount" and "account". For "account" click "add level" and add other parameters.


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 9:10 pm
by Alfred Butler

Ok

I double checked to make sure all is well with the server and my JSON data.
My tests, using the Chrome plugin Postman says all is well.
So it's functioning.

In Appery.io I receive this:
{
"status":"403 Forbidden",
"url":"http://xx.xx.xx.xx/mwallet/rest/cashi...",
"response":""
}

If you need the REAL ip address I can send it to you privately or you can log into my account and do the test yourself.

This is going well but also remember that the data i am using in the JSON request, needs to be BASHED with different values. So obviously the hard coded examples will work but I'll need you to show me via the Appery API on how to get at the data or at least expose the variable that holds it.

I'm sure it will be exposed somewhere.

Thanks al


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Fri Nov 01, 2013 9:23 pm
by Maryna Brodina

Please send screenshot with settings at a href="mailto:support@appery.io" rel="nofollow"support@appery.io/a and share the project.


AJAX Parse error: Status 200: Unable to parse JSON string

Posted: Sun Nov 03, 2013 3:00 am
by Igor

Hello,

It looks like you should add authentication key to the service URL if you want to execute put queries. Do you have any API docs for your service?