Cant seem to make AJAX to get response from the server

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     
   }   
 });
 }

Hi Alex,

I tried opening your server URL with a callback parameter like this:
http://urotrulegur.com/ajaxTutorial/ajax-response-2-app.php?callback=callback

and the response I get is:

girl this is a php responsecallback(girl this is a php response)



callback(["This is a response from the server!"])

thanks fretburner!
i was debugging my code with firebug today, and it turns out i had an error in a code just above the $.ajax call, i was using a cordova phonegap function, yet i forgot to add the plugin it belongs to.

at any rate thank you a lot for trying to help me.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.