mccabec123's Profile User Rating: -----

Reputation: 18 Tradesman
Group:
Active Members
Active Posts:
234 (0.17 per day)
Joined:
03-March 11
Profile Views:
4,461
Last Active:
User is offline Aug 09 2014 07:44 AM
Currently:
Offline

Previous Fields

Country:
GB
OS Preference:
Mac
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
PC
Your Car:
Who Cares
Dream Kudos:
0

Latest Visitors

Icon   mccabec123 has not set their status

Posts I've Made

  1. In Topic: Looking to create some shutters for a parallax website

    Posted 9 Aug 2014

    Nobody able to give me a hand with this then?
  2. In Topic: Issues passing values between methods/functions and jquery

    Posted 3 Aug 2014

    It's cool anyway, I fixed it. The getJSON request was returning the JSON within an array, should have noticed that by examining the JSON output. Silly mistake as per usual.

    So I ended up having to access like so:

    val[0].content
    
  3. In Topic: Issues passing values between methods/functions and jquery

    Posted 2 Aug 2014

    Nothing, I just don't really understand the problem that you're pointing out? As surely the problem that I'm currently pointing out would still exist even if I was pulling the data from data-attributes rather than from an array that I've compiled, and I'd still need to get the real ID and store it in the data-attribute anyway using ajax, but it's failing when I'm trying to assign and use the variable, so I need a solution to that before I can solve the data-attribute issue, as a data-attribute will not fix the problem I'm having.
    [{"title":"Another test post","0":"Another test post","posted_by":"mccabec123","1":"mccabec123","content":"Another test post, for testing","2":"Another test post, for testing","posted_at":"2014-07-31 05:51:42","3":"2014-07-31 05:51:42","4":"mccabec123","firstname":"Conner","5":"Conner","surname":"McCabe","6":"McCabe"}]
    


    I've added here a sample JSON response that I get when I type the URL into the browser, so there is no issue with the script we are using with the AJAX, it's solely the Javascript.

    I've also updated the script to use .on('event') as well, here is the current script:

    $.getJSON("/client-ajax/last-ten-posts.php", function(data){
    	$.each(data, function(k, val) {
    		post_ids.push(val.id);
    	});
    }).done().success(function(data){
    	$.getJSON("/client-ajax/last-ten-posts.php?post-id=" + post_ids[0], function(val){
    		alert(post_ids[0]+ val.id + "");
    		$("#postContainer").empty();
    		$("#postContainer").append("<p class='title'>" + val.title + "</p><div class='post-icon'></div><pre>" + val.content + "</pre><p class='footnote'>Posted by " + val.firstname + " " + val.surname + " at <time datetime='2014-06-10'>08:52</time> GMT+00 on the <time>10-06-2014</time></p>");
    	});
    });
    
    $(".previous-button").on('click', function(){
    	$.getJSON("/client-ajax/last-ten-posts.php?post-id=" + post_ids[i].id , function(val){
    		i--;
    		$("#postContainer").empty();
    		$("#postContainer").append("<p class='title'>" + val.title + "</p><div class='post-icon'></div><pre>" + val.content + "</pre><p class='footnote'>Posted by " + val.firstname + " " + val.surname + " at <time datetime='2014-06-10'>08:52</time> GMT+00 on the <time>10-06-2014</time></p>");
    	});
    });
    $(".next-button").on('click', function(){
    	$.getJSON("/client-ajax/last-ten-posts.php?post-id=" + post_ids[i].id , function(val){
    		i++;
    		$("#postContainer").empty();
    		$("#postContainer").append("<p class='title'>" + val.title + "</p><div class='post-icon'></div><pre>" + val.content + "</pre><p class='footnote'>Posted by " + val.firstname + " " + val.surname + " at <time datetime='2014-06-10'>08:52</time> GMT+00 on the <time>10-06-2014</time></p>");
    	});
    });
    
  4. In Topic: Issues passing values between methods/functions and jquery

    Posted 1 Aug 2014

    I'll explain what I'm trying to do and maybe it'll give you a better understanding. I'm trying to create a blog post loader, which brings in the next blog post, then slides the old one away and loads the new one in. So storing the attributes in the elements isn't really viable, as they're being composed by the jquery anyway, so it would be redundant.
  5. In Topic: Issues passing values between methods/functions and jquery

    Posted 1 Aug 2014

    By deferred's are you talking about .done().success() etc?

    Yeh I understand that it's not amazing, but I'm still learning jQuery, think my knowledge is okay, but I lack in the more complex situations.

    If you could give me an example of how to achieve this using attributes and parameters that'd be great as I'm not entirely how that would help atm.

    Thanks again.

My Information

Member Title:
D.I.C Head
Age:
23 years old
Birthday:
July 19, 1991
Gender:
Location:
Scotland
Full Name:
Conner Stephen
Years Programming:
6
Programming Languages:
PHP, C, JavaScript, C++, MySQL, BASH Scripting, Databases, Programming Theory, Ruby, RoR

Contact Information

E-mail:
Private

Friends

Comments

mccabec123 has no profile comments yet. Why not say hello?