• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Stuck with jQuery (post) and CI

Hi all,

I could really use some help here, been banging my head to the wall for past two days Sad

A really simple script:
step2.php (views)
<input type="button" id="bagView">test</input>
        $('#bagView').live('click', function(){
            $.post("http://core_igniter/index.php/test",function(data) {
                alert("Data Loaded: " + data);
test.php (controller)
class Test extends Controller
    function index()
and test.php (views)
echo "test";

That's all.
Problem is that I do not receive string 'test' with jQuery post code Sad
If I open URL (http://core_igniter/index.php/test) in the browser it is working.

When I click on the button to trigger JS, it does execute it - I can see it in Firefox (firebug). But then it says: "Data Loaded: " (without string test behind it).

What the hell am I doing wrong here Sad


Ok, small addition:

It does not work between 2 domain names;
step2 is on server1;
controller is on server2.

I have placed controller on server1 as well - then it is working Sad

So, this looks like network / two servers issue?

Any help is appreciated! Smile

Another note, just found it on Google:
jQuery does not allow cross domain queries. But this seems so 'useless' then and frankly I can not believe that this is the case. That would also mean that for example many of Google's own Ajax scripts would not work (maps, search - you name it).

Where is the flaw in my logic here? Sad


Well, I solved it like this:

view (jQuery.post()) calls local controller, local controller fires up REST library which performs remote check and returns it to view.

I also saw there are some other options to be able to do cross-domain Ajax calls, but those seem quite 'damaging' and not really trustworthy - so I will stick to this Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.