views:

77

answers:

3
A: 

I'm not a PHP guy, but does removing the leading / in your directory string (/admin/get_galleries) fix it? You'd append admin/get_galleries instead, since your link variable already has the trailing /.

David Hoerster
Unfortunately not. I updated the code for that. In my actual situation, I'm not using the link variable, I just pass in the full URL.
gamerzfuse
Is the GET going to the same domain as the page that it's hosted on? I'm assuming it is, but thought I'd ask.
David Hoerster
Also, if you replace the `$("#gallery...").html(gals)` call with an `alert(gals)`, what do you get? Have you monitored the call with Fiddler or Firebug -- anything coming back from the server?
David Hoerster
a) The server is the same, so the Same Domain Policy doesn't apply. b) I have tried alerting it, and I get absolutely nothing back. I used firebug and even tried to console.log the data, but I never get a response.
gamerzfuse
Do you know that it's getting processed on the server side - debugging/tracing/output-to-text-file/etc.? Sorry for the obvious questions.
David Hoerster
have you tried navigating the get url from the browser directly?try to navigate this on the browser "http://www.example.com/admin/get_galleries" then view the source of when it's done. Inspect if there is a result, or the results are valid.
jerjer
it would also be helpful if we can have a glance at the php code returning the results.
jerjer
Sorry for the delays. The answer is yes, I have navigated directly to the URL and it outputs the exact HTML that I want. (it just shows the HTML). I have tested various outputs from it, but I'm here because it never seems to output anything.
gamerzfuse
+2  A: 

I'm guessing that what you want to do is update some data via $.post then get the updated data using get? In that case you have an issue since $.post and $.get is asynchronous, meaning that the browser wont wait for it to finish before proceeding in the script.

What this means is that your script will call $.post and $.get almost simultaneously, instead, try placing your get inside the callback for $.post like so:

$('#submit').click(function() {

    var nam = $('#name').val();
    var par = $("#parentCategory").val();
    var dat = $("#catDate").val();

    $.post("<?php echo site_url('admin/add_gallery'); ?>", {name: nam, parent: par, cat_date: dat}, function() {
        if (par != 'undefined')
        {
            $('#next_tab').click()
        }
        else
        {
            $("#gallery").click(),
            $("#name").val('')
        }
        $.get("http://www.example.com/admin/get_galleries", function(gals)
        { // Get the Contents of Drop Down Gallery Select
            $("#galleryChoose").html(gals);
        }); 
    });



    alert('yop');       

});
Kristoffer S Hansen
I thnk that's it. I should have seen that. +1
David Hoerster
I will definitely look into this, as that makes sense. I believe I did try that though, however it just made things flicker and look like the page was reloading, but didn't work. I will double check it all and try to implement it properly.
gamerzfuse
You should also check out Firebug (http://www.getfirebug.com) and see if the output you get from http://www.example.com/admin/get_galleries is the output you expect there to be. (Or, you know, just go to the address)
Kristoffer S Hansen
As I noted on D Hoerster's answer, I used Firebug extensively and checked the URL, it sends back HTML exactly what I want.
gamerzfuse
Didn't work, but I'm sure you were right. Substituted the completely unnecessary GET for a much simpler LOAD command.
gamerzfuse
A: 

CodeIgniter comes with $_GET disabled by default. You have to enable it in order to use it. Take a look here: CodeIgniter User Guide, Security

Luis
Yeah, but it works perfectly fine in another section of my site where I get the cart contents using almost identical syntax.
gamerzfuse
Maybe you are using a bad route.Make sure you are using <?= site_url('controller/method'); ?> along your requests.I think that the problem is caused by jQuery, it can't make cross domain calls(even between 'http://localhost' and 'http://127.0.0.1'). If you want to do that you need to use JSON.Hope it helps.. I had similar problem.
Luis