Jump to content

spiderwell

Members
  • Posts

    1,008
  • Joined

  • Last visited

Posts posted by spiderwell

  1. I am having a go at making a site with a lot of jquery ajax stuff.

     

    I have an image with a class of manageusers, and when clicked it loads up the users listings. I think want to turn the paging links to do the same thing but also pass which page, however it wont pass them as a link it just does a normal GET method to the page. So i tried an laternative method of turning the link into a span with the same classname, and adding cusotm attributes to pass the info instead and that doesnt seem to work either!!

     

    any help would be apprciated, I know there is a simple way to do it, but I cant seem to find one online. in my code I have only 1 record per page just for testing

     

    $('.manageusers').click(function(e) {
    $("#loading").show();
    var thiscache = $(this);
        page = thiscache.attr("page"); 
        direction = thiscache.attr("direction"); 
        order = thiscache.attr("order");
        var dataString = "page="+ page + "&order=" + order + "&direction=" +direction;     
    alert(dataString);
    $.ajax({  
    			type: "GET",  
    			url: "a/a_manageusers.php?",  
    			cache: false,
    			success: function(html) {
    			data: dataString,  
    			$('#admincontainer').html(html); 
    
    			},
    			error: function() {
    			$("#admincontainer").show();
    			$('#admincontainer').html('<span class="red">There was an error fetching the users</span>'); 
    			}
    		});  
    $("#loading").fadeOut(800);
    e.preventDefault();
    
    

     

     

    then the html in the page looks like this:

    <div id="admincontrol">
    <img src="../images/users_two_48.png" class="manageusers" border="0" width="30">
    </div>
    
    
    <div id="admincontainer">
    <ul style="margin: 0px; padding: 0px;">
    <li style="background-color: rgb(238, 238, 255);" id="userorder_28" class="listtext" onmouseover="style.backgroundColor='#ffffff';" onmouseout="style.backgroundColor='#eeeeff';">
    <div class="userfullname">
    Johnny Alpha</div><div class="usergallery">
    <span style="font-style: italic;"></span>   </div><div class="username">
    Johnny</div>
    </li>
    
    <li id="paging" class="listtext">  
    <span style="font-style: italic; float: right;">Page 1 of 3 </span>  1  
    <span class="manageusers" order="ID" direction="DESC" page="2">2</span>
    <span class="manageusers" order="ID" direction="DESC" page="3">3</span>
    </li>
    
    </ul>
    </div>
    

  2. my flat has a shared washing machine and drier with the other flat in the building. a pound in the machine gets you 1 hour, which is only enough time for the quick wash! the drier is 20pence for 7 minutes lol

     

    I got myself to only washing all my stuff in one quick wash once a week, lol.

  3. sure but all it outs puts is 0 or 1.

    also if i do alert(html) or use .html(html) it puts 1 or 0 into that so I cant work out why javascript isnt executing the if statement correctly.

     

    <?php
    
    require_once("../../classes/sentry.php");
    require_once('../../classes/dbconnector.php');
    //create objects for page
    $connector = new DbConnector(); //create database connection
    $sentry = new Sentry();
    //set up page variables
    $var_username = ""; //default
    $var_password = ""; //default
    
    if (isset($_POST['username'])) $var_username = $_POST['username'];
    if (isset($_POST['password'])) $var_password = $_POST['password'];
    
    if($sentry->checkLogin($_POST['username'],$_POST['password'],10))
    {
    
    echo "1";
    }
    else
    {
    
    echo "0";
    }
    

     

    I have passed the variables directly to a_login.php in the address bar to check it outputs both 0 and 1, and it does.

    If i log in correctly i get the message 'The username or password was incorrect 1' the 1 is the html passed back, so in my mind it should be returning the if not the else. if i log in incorrectly i get the message 'The username or password was incorrect 0'. its very annoying!!

     

  4. i have a login form, thats ajax submitted, and response page spits out 0 or 1 on success or failure (of login) but I cant seem to get the jscript to notice the differnce!!. It always executes the else statement from beow. Any ideas? its driving me mad!

     

    var dataString = 'username=' + name + '&password='+password;  
    		//alert (dataString);return false;  
    		$.ajax({  
    			type: "POST",  
    			url: "a/a_login.php",  
    			data: dataString,  
    			cache: false,
    			success: function(html) { 
    			alert(html);
    			if (html == "1") {
    					$('#messagebox').html('Login successful, loading site...'+html); 
    					$("#messagebox").fadeIn(800);
    					$('#logincontainer').fadeOut(1500);
    				}
    				else {
    					$('#messagebox').html('The username or password was incorrect'+html); 
    					$("#messagebox").fadeIn(800);
    
    				}
    
    			},
    			error: function() {
    			$("#messagebox").show();
    			$('#messagebox').html('There was an error with the login'); 
    			}
    		});  
    		return false; 
    

  5. when you have your login script do you store the userid into the session variable?  there must be some mechanism that you use to keep users logged in and identify them. use that to extract your userid.

  6. maybe its me but that seems quite a test for a junior position. I was expecting something more like a form with validation or paging through a dataset. making a simple game I would say is more moderate level than junior.

     

    I don't mean to sound condescending, but I was a teaching assistant on a first-year university level programming course (Object Oriented Programming and Design). The course load was 7.5 ECTS-credits. I would have expected my students to be able to solve that problem. Indeed the exam was creating a Tron-like game with a GUI and simple AI strategies for computer based players using Java. The only programming course prior to that one was Introduction to Programming, which used functional programming, so the for many students, it was the first time they had to program imperatively.

     

     

    I think perhaps I need to have some education, Ive been scripting for a long time, and can deal with most demands that small to medium datadriven websites would have. I only recently started to do OOP but I have only learnt from books and online resources and forums similar to this one. I would be amazed if I could get this test up and running in an hour or two. Maybe I ought to have a go just to see  :D, also I am off to google factory method! lol

    I think  my biggest downfall is I only really know what I have had to learn, so many things have slipped past me, particularily in theory of programming and structure of code etc. I never forget the day i discovered recursion by accident/necessity, and thought I had found something AMAZING, only for my mate to laugh at me, but way I see it, I can't be that dumb if I managed to create it in the first place without knowing it before!!

  7. maybe its me but that seems quite a test for a junior position. I was expecting something more like a form with validation or paging through a dataset. making a simple game I would say is more moderate level than junior.

     

    good luck though.

     

    The test isn't difficult if you have a solid grasp of OOP fundamentals.  Not syntax, but the real fundamentals.

     

    The test is asking a few things:

     

    1. Does the person know how to use abstract classes?

    2. Does the person know the Factory Method, perhaps the most common creational pattern in use?

    3. Can the person use objects in a loop while testing for certain edge cases (the special abilities of each warrior)?

     

    OOP is the dominant programming paradigm.  That's not a value statement, merely an observation.  It's something new developers need to learn if they want to work for someone else.

     

    Well I con't have OOP sussed yet, but I have held positions in companies which were definately above junior or entry level and they didn't require any OOP, mind you that said my new role does and i'm learning fast!!!

  8. maybe its me but that seems quite a test for a junior position. I was expecting something more like a form with validation or paging through a dataset. making a simple game I would say is more moderate level than junior.

     

    good luck though.

     

     

×
×
  • 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.