Jump to content

Solarpitch

Members
  • Posts

    708
  • Joined

  • Last visited

Everything posted by Solarpitch

  1. Guys, many thanks for your help! I totally understand now cheers!
  2. Yeah, while I can mange looking through arrays or objects... I'm confused as to how I can loop through what I just created.
  3. Apologies, arrays are not my strong point.. indenting it would be a task in itself. And I still havent a clue what the problem is. EDIT: I'm thinking I might need to go down the route of something like but not really sure. <?php foreach($get_questions as $key => $value){ ?> ..
  4. Hey Guys, I'm after creating an array of some description and cant seem to figure out how to get the data from it: The array looks like this... Array ( [1] => Array ( [0] => stdClass Object ( [id] => 1 [question] => Sprint Planning duration: between 2-4 hours [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 1 ) [1] => stdClass Object ( [id] => 1 [question] => Team used Roman Voting to agree what user stories will be part of the sprint [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 2 ) [2] => stdClass Object ( [id] => 1 [question] => Backlog is correctly prioritized [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 3 ) [3] => stdClass Object ( [id] => 1 [question] => Team discuss user story and acceptance criteria for each story and have clear understanding of what is expected [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 4 ) [4] => stdClass Object ( [id] => 1 [question] => Each user story in the sprint is Sprint Ready [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 5 ) [5] => stdClass Object ( [id] => 1 [question] => There are between 5-20 user stories in the sprint [question_category] => 1 [created] => [category_name] => Sprint Planning [question_id] => 6 ) ) [2] => Array ( ) [3] => Array ( ) ) I'm trying this but get the below error. $get_questions holds the above array. <?php foreach($get_questions as $question){ echo $question->category_name; ?> error: A PHP Error was encountered Severity: Notice Message: Trying to get property of non-object
  5. The white space was an issue. Works when I do: urlencode(trim($sourceId)) Sojust needed to trim that off.
  6. Hey Guys, I'm retrieving a name from a POST and using urlencode() but it seems to be giving an incorrect url. ... $sourceName = $_POST['val']; // echos here as " Conor Maynard " echo $url = "http://www.site.com/api/artist/details?aname=".urlencode($sourceName)."&id=mymHPtI3wp&format=xml"; The output is: http://www.site.com/api/artist/details?aname=%0A++++++Conor+Maynard%0A++++&id=mymHPtI3wp&format=xml If I just do $soureName = "Conor Maynard"; as hardcoded it works fine, but doesnt seem to like the value when assigned from the POST.
  7. No whitespace after PHP tag also tried: var res = $.trim(response); obj = JSON.parse(res); but still seem to get the same message,.
  8. Hey Guys, I'm sending a php array in JSON to a JS function like this: $arr= array( 'a' => "Gerard", 'b' => "Jonathan" ); echo json_encode($arr); I can see it's being sent like: {"a":"Gerard","b":"Jonathan"} However, when I try and retrieve it in the javascript function below I get an error: SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data obj = JSON.parse(response); $.post('http://site.comi/ajaxApiCall', 'val=' + val, function (response) { obj = JSON.parse(response); alert(obj['a']); }); Still get the error even if I dont use JSON.parse. Just not sure where I'm going wrong.
  9. It actually works when I replace the return with echo.
  10. When I try do that: obj = JSON.parse(response); alert(obj.count); I just get this error. Dunno why :-\ SyntaxError: JSON.parse: unexpected end of data obj = JSON.parse(response);
  11. Hey Guys, Just trying to pass a php array to a Javascript function but I keep getting undefined. I'm sure my syntax is slightly incorrect. PHP ... $arr = array(); $arr[0] = $this->load->view('video',); $arr[1] = "A String"; return json_encode($arr); // this returns to the below Javascript $.POST responce. Javascript ... $.post('http://mysite.com//api/ajaxApiCall', 'val=' + val, function (response) { alert(response[0]); alert(response[1]); });
  12. Hi Guys, I have the following simple carousel code that slides a list of items left and right. Image below also shows you how it currently looks with the first active item to the left. Using the code below is there any way I can have the first active item in the center of the carousel. Ideally I want to be able for the carousel to be able to jump to a specific item also. if I have the following and I've been passed data-id of "104" lets say, I want this to be the center active item in the carousel when I populate it. <ul> <li data-id="100"></li> <li data-id="101"></li> <li data-id="102"></li> <li data-id="103"></li> <li data-id="104"></li> <li data-id="105"></li> </ul> var item_width = $('#navigation_ul li').outerWidth() + 10; if(where == 'left'){ var left_indent = parseInt($('#navigation_ul').css('left')) + item_width; }else{ var left_indent = parseInt($('#navigation_ul').css('left')) - item_width; } $('#navigation_ul:not(:animated)').animate({'left' : left_indent},100,function(){ if(where == 'left'){ $('#navigation_ul li:first').before($('#navigation_ul li:last')); }else{ $('#navigation_ul li:last').after($('#navigation_ul li:first')); } $('#navigation_ul').css({'left' : '-300px'}); });
  13. Hi Guys, I have a simple slider I've code with jQuery that moves through a list of <li> elements. I want the user to have a option to show smaller thumbs and in doing so the slider changes to 2 rows of <li>. I've attached an example of what I'm talking about. Not sure what the best way to approach this is, maybe more of a css question? When the user switches between the 2 views I want the next <li> in the large view, to be the element below in the small view. Any help would be great.
  14. figured it out.// $(".ppc_thumb[data-id=" + dataID + "]").addClass('ppc_thumb_playing');
  15. Ah right, It's sorta working now, the only thing is it applies the class to all of the ppc_result div's.. I just want to apply the class to that div with the specific data-id..
  16. Hey Guys, I have a div with a data attribute of id. I can get the value fine ("278715"). How can I add a class to this div using jQuery. <div class="ppc_result" data-id="278715"></div> Here's what I'm trying but doesnt seem to work. $("data-id").val(videoData['id']).addClass('ppc_thumb_playing');
  17. Hey Guys, Just wondering how I can achieve the same effect that vevo have done here http://www.vevo.com/videos#?order=MostRecent When you hover over an thumbnail, it overlays an image of a play icon. I've tried putting the image over the main thumbnail and setting it to hidden, but there must be a better way than that?
  18. Hey, I have the following code that slides a div from left to right when you click on #Link. This works fine but when I click it again I want to slide it exactly the same from right to left. Problem with this is it just keeps sliding it right everytime I click the link. Tried using toggle but no matter what margin value I had specified, it slid the div right off the page. $(document).ready(function(){ $('#link').click(function() { $('.hidediv').animate({'marginRight' : "-=295px"}, 300); return false; }); });
  19. Hey Guys, Please look at the attached image. I have a div call left and right panel. When I hide the right panel using JS which I've created, I want to center the left panel in the wrapper like shown. I've tried a few different options using pargin auto and % scaling but not which much look. [attachment deleted by admin]
  20. Hey Guys, I have a snippet of XML here.. <courses> <course> <id>70</id> <name>Marketing and Social Media</name> <dates> <date> <instance_id>6747</instance_id> <location /> <course_type>Day</course_type> <date_available>2011/07/13</date_available> <time_start>9:30</time_start> <time_end>17:00</time_end> <availibility>7</availibility> <running_dates> <running_date>2011/07/13</running_date> <running_date>2011/07/14</running_date> </running_dates> </date> </dates> </course> I'm trying to run xpath query to return all the courses and running dates associated with it but I dont understand how I get the running_dates? This is what I have.. <?php $xmlstr = "../wp-content/themes/iact/courses.xml"; $xml = new SimpleXMLElement($xmlstr, NULL, TRUE); foreach ($xml->xpath('//date/running_dates') as $date) { $t = "<p class='heading'>". $date->course_type."</p> <div class='content'>".$date->running_date."</div>"; // do I need to go into another foreach here to loop all of the running dates? hardly? echo $t; } ?>
  21. This sorted the problem. And Sean your right, doesnt make sense to have two ID's the same but Facebox basically copied the one that's set to display:none; and shows it in the lightbox (Facebox). Thanks for your help guys.
  22. I just ran that and it returns 2? ... U'm but there's only one in the code. When it displays it in the lightbox I wonder if it's referencing it twice because of that.
  23. It seems to be that the jQuery only reads from the value of the textfield when it is not display using Facebox. When we use Facebox to popup the textfield and click insert, it still reads from the textfield on the page so to speak, like, kinda ignores the value in the lightbox. I dont have an example page at the moment but can probably set one up later if you have no other suggestions.
  24. Actually, found the solution... If you are passing it a filename instead of a string, the third parameter needs to be TRUE, e.g.: $sxe = new SimpleXMLElement('they_wont_let_me_put_a_url_here', NULL, TRUE); Thanks for your help.
×
×
  • 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.