I'm working on a PhoneGap project that uses jQuery AJAX to get data from our online app.
Here is the code I am using:
$.ajax({
type: 'GET',
url: home ,
async: false,
dataType: "jsonp",
jsonpCallback: 'jsonCallback',
data: {action: 'get_survey', survey: survey_id},
success: function (result) {
$.mobile.loading( 'hide', {});
display_survey(result);
},
error: function (request,error) {
$.mobile.loading( 'hide', {});
alert(error);
}
});
Here is the data that is being returned from the server:
jsonCallback({"symptoms":{"ent":["Does not pay attention to details or makes careless mistakes wiht, for example, homework","Has difficulty keeping attention to what needs to be done","Does not seem to listen when spoken to directly","Does not follow through when given directions and fails to finish activities (not due to refusal or vailure to understand)","Has difficulty organizing tasks and activities","Avoids, dislikes, or does not want to start tasks that require ongoing mental effort","Loses things necessary for tasks or activities (toys, assignments, pencils or books","Is easily distracted by noises or other stimuli","Is forgetful in daily activities","Fidgets with hands or feet or squirms in seat","Leaves seat when remaining seated is expected","Runs about or climbs too much when remaining seated is expected","Has difficulty playing or beginning quiet play activities","Is 'on the go' or often acts if 'driven by a motor'","Talks too much","Blurts out answers before questions have been completed","Has difficulty waiting his or her turn","Interrupts or intrudes on others' conversations and\/or activities","Argues with adults","Loses temper","Actively defies or refuses to go along with adults' requets or rules","Deliberately annoys people","Blames others for his or her mistakes or misbehaviors","Is touchy or easily annoyed by others","Is angry or resentful","Is spiteful and wants to get even","Bullies, threatens, or intimidates others","Starts physical fights","Lies to get out of trouble or to avoid obligations (ie, 'cons' others)","Is truant from school (skips school) without permission","Is physically cruel to people","Has stolen things that have value","Deliberately destroys others' property","Has used a weapon that can cause serious harm (bat, knife, brick, gun)","Is physically cruel to animals","Has deliberately set fires to cause damage","Has broken into someone else's home, business or car","Has stayed out at night without permission","Has run away from home overnight","Has forced someone into sexual activity","Is fearful, anxious or worried","Is afraid to try new things for fear of making mistakes","Feels worthless or inferior","Blames self for problems, feels guilty","Feels lonely, unwanted or unloved; complains that 'no one loves him or her'","Is sad, unhappy or depressed","Is self-conscious or easily embarrrassed"]},"performance":{"ent":["Overall school performance","Reading","Writing","Mathematics","Relationship with parents","Relationship with siblings","relationship wiht peers","Participation in organized activities (eg, teams)"]}})
Right now, I am testing the app in a browser. When the PG app is called from the same server as the online app, it works fine. However, if the PG app is on a different server, I get a 'parseError' from jQuery and the error function is triggerd.
However, when I look in the console, I can see that the PG app is receiving all of the data.
Am I missing something when I set-up the JSONP call?