Pregunta

I have a .php file from another server which processes data. This data is tabulated. So whenever I call this page using $.post with the right parameters, its response is nothing. I checked my code and maybe the header is the one responsible for it. What I want actually is to return my tabulated data so that I can populate it to another page. My header is like this, header("Content-type: application/json");. What am I missing?

$.post('http://333.333.33.33/reporting/table.php?loc_id='+locid+'&loc_type='+loctype+'',{loc_id:locid, loc_type: loctype},function(data){
    $('table#default_table').hide();
    $('div#generated_table').html(data);
});

that is how I call my $.post.

¿Fue útil?

Solución

You my friend have become yet another victim of the Same Origin Policy - luckily, this can be "worked around" by using a method called JSONP. This does, however, require a GET rather than a POST request. I myself had to use this, and I had no idea about how it worked, so I asked a question and got a wonderful answer!

Otros consejos

You need to communicate between 2 different domains right?

You need to use JSONP here instead JSON. Check Detail

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top