Welcome Guest, Not a member yet? Register   Sign In
Stuck with jQuery (post) and CI
#1

[eluser]smilie[/eluser]
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)
Code:
<input type="button" id="bagView">test</input>
        [removed]
        $('#bagView').live('click', function(){
            $.post("http://core_igniter/index.php/test",function(data) {
                alert("Data Loaded: " + data);
        });
        });
        [removed]
test.php (controller)
Code:
class Test extends Controller
{
    function index()
    {
        $this->load->view('test');
    }
}
and test.php (views)
Code:
<?php
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

Thanks!
Smilie
#2

[eluser]smilie[/eluser]
Hm...
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
#3

[eluser]smilie[/eluser]
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

Regards,
Smilie
#4

[eluser]smilie[/eluser]
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

Regards,
Smilie




Theme © iAndrew 2016 - Forum software by © MyBB