Jump to content

getJSON working on localhost just not online.


c_shelswell

Recommended Posts

Hi I can't figure this out. I'm populating a select box based on the selection of another. This is working fine on my machine but not online. Is there a reason this might happen.

 

my jquery on the first page:

$(function()
    {		 
	$("select#membersOrPublic").change(function()
	 {
		$.getJSON("get_categories.php",{id: $(this).val(), ajax: 'true'}, function(j)
		{
			var options = '';
			for (var i = 0; i < j.length; i++) 
			{
				options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
			    
			    if (j[i].optionValue == 0)
			    {
				  // no results have been returned
			    }

			}

			$("select#categoryList").html(options);
		})
	})
})

 

and my get page

$cats = $db->selectFromDB('site_categories', '', "where area='".$_GET['id']."'");


if (count($cats) > 0)
{
$json = "[";

foreach ($cats as $k => $v)
{
	$json .= "{optionValue: '".$v['id']."', optionDisplay: '".$v[DEFAULT_LANG]."'},";
}

$json = substr($json, 0, -1);

$json .= "]";

echo $json;

}
else
{
$json = "[";

$json .= "{optionValue: '0', optionDisplay: 'NO CATEGORIES PLEASE CREATE ONE'}";

$json .= "]";

echo $json;

}

 

I'm not getting any errors from my get page just can't figure why it's not working online.

 

any ideas?

 

Cheers

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.