trying to get data from external php file

601 Views Asked by At

what's wrong with this code of mine... I'm new to jquery especially 1.5 ver....

function loadQry(str)
{
     $.ajax({
          type: "POST",
          url: "fillpage.php",
          data: "prodcode="+str,
          success: function(response_data){
                     $('s_content').html(response_data)
                   }
          });
}

The problem I have is that, it's not returning any data from the external php. I'm confused..

In 1.4 using XMLHttpRequest I can do it and it's doing fine. but this code certainly bugged me LOT..

2

There are 2 best solutions below

1
On BEST ANSWER

function loadPostQry(str) { 
    $.get( 'fillpage.php','prodcode='+str, function(data) { 
        $('#s_content').html(data); 
    },
    "html" ); 
}

I'm assuming you meant this?

4
On

For jQuery version 1.5, please read the updated jQuery Ajax docs to get familiar with jqXHR object:

As of jQuery 1.5, the success callback function is also passed a "jqXHR" object (in jQuery 1.4, it was passed the XMLHttpRequest object)

The docs also give you an example code using jqXHR.

$.get now has slightly modified interface:

jQuery.get( url, [ data ], [ success(data, textStatus, jqXHR) ], [ dataType ] )