Hey guys,
I am building an app to manage and maintain dogs at a dog shelter. I am new to JSONP, and it seems that i am doing something totally wrong, does anyone have any idea what it is?
here is the code:
$( document ).ready( function(){
$('#searchDoggy').click(function()
{
var did=$('#inputDoggy').val();
if(did.length>0)
{
$('#resultBox').html("Searching "+did+"...");
//call jsonp request
getDog( did);
}
else
$('#resultBox').html("Sorry, the string is too short!");
});
});
function onDeviceReady()
{
//on phonegap tools loading
}
function getDog(dogId)
{
//get AJAX
$.ajax({
url: 'http://urotrulegur.com/ajaxTutorial/ajax-response-2-app.php',
type: 'GET',
datatype: 'jsonp',
data: {
q: dogId,
},
success: function( response )
{
window.alert("Data returned form the server: "+response);//print the response as it is, for now
$('#resultBox').html(response);
console.log( response ); // server response
}
});
}