Jump to content
MakeWebGames

Sim

Members
  • Posts

    2,392
  • Joined

  • Last visited

  • Days Won

    62

Everything posted by Sim

  1. Sim

    jQuery round 4.. :)

    Edit: I think I need to remove var_dump. LoL... I just now seen this. I will try and post results. Here's a partial of the PHP code just to see what is returned: $results[] = array( "reward" => false, "msg" => $this->fail[mt_rand(0, count($this->fail))] ); } } die(var_dump($results));
  2. Sim

    jQuery round 4.. :)

    The scavageData is shown in alert now from previous post code: Here's the alert data: like the code comments say I can't get the days from my array jq.get(url) .always( function(data){ scavageData = data; scavageCounter = 0; alert(1); //1 alert(scavageData[0][0]); //a alert(scavageData[0]["msg"]);//undefined alert(scavageData[0].msg); //undefined alert(scavageData);//disolays screenshot setTimeout(showScavageResults(), 1000); alert(3); });
  3. Sim

    jQuery round 4.. :)

    I have thought if that. Let me try that. I would still think it would still show my alert before using the scavageData though. Edit: I'm one are close to getting it was. I can call the functions now. It seems like the jQuery Ajax call must completed before it can call after function with timeout. The problem now it's I can't access the data for some reason. I done tried every variation of the array. I commented the outcome of the alert next to the scavageData alerts.
  4. Sim

    jQuery round 4.. :)

    The code is now this: var scavageTimer; var counter; var scavageData; var scavageCounter; function performScavage(){ //e.preventDefault(); var timez = jq("#scavageTimes").val(); var url = "?page=scavage&times=" + timez; alert(timez); if(timez <= 0) { alert("You have to search the streets at least one time!"); return false; } jq.get(url, function(scavageData) { alert(scavageData); scavageCounter = 0; alert(1); setTimeout('showScavageResults', 1000); alert(3); }); } function showScavageResults(){ alert(2); jq("#scavageResults").append(scavageData[scavageCounter].msg); scavageCounter++; } I receive the alerts 1 and 3. So the settimeout doesn't error. But it's not executing the code withing function at all.
  5. Updated Files. If you have previously purchased this mod, I recommend you replace the TPL files as it fixed a seriously flawed design issue on non-mobile devices.
  6. Cause you got smarter and realized it was debugging? 🙂
  7. Sim

    jQuery round 4.. :)

    i wish I could use the code tags Edit: my markup is correct. Phone auto corrected it. <div id="scavageResults"></div>
  8. I load my page with some of my previous jQuery code. The new page I load some new HTML: Partial HTML: <div I'd="scavageResults"></div> The JavaScript that is loaded is: var scavageTimer; var counter; var scavageData; var scavageCounter; function performScavage(){ //e.preventDefault(); var timez = jq("#scavageTimes").val(); var url = "?page=scavage&times=" + timez; alert(timez); if(timez <= 0) { alert("You have to search the streets at least one time!"); return false; } jq.get(url, function(scavageData) { alert(scavageData); scavageCounter = 0; alert(1); setTimeout('showScavageResults()', 1000); }); } function showScavageResults(){ alert(2); jq("#scavageResults").append(scavageData[scavageCounter].msg); scavageCounter++; } The problem is it never appends my scavageData. I think it's not showScavageResults. All my other alerts get down. scavageData returned is:
  9. Worked for me @Veramis
  10. "since the form was not submitted using a button". The form does getting submitted using a button. Now I get to pick on yo for giving me wrong URL:
  11. So the forms with buttons seem to go unregonized by the modules. <button type="submit" name="submit" value="true" class="btn">Update</button> The Ajax: jq("#php__container").on('submit', 'form', function(e){ e.preventDefault(); alert(jq(this).serialize()); var url = jq(this).attr("action"); jq.ajax({ type: "POST", url: url, data: jq(this).serialize(), success: function(data) { alert(data); jq("#php__container").html(data); // show response from the php script. } }); return false; }); $this->methodData->submit will always be empty. Every other fo element will have it's value. Anyone got any ideas on what's going on?
  12. Edit: deleted old code in this post. This works. jq("#php__container").on('submit', 'form', function(e){ e.preventDefault(); var url = jq(this).attr("action"); alert(url); return false; }); Problem being that all GL forms action URLs are ="" so, I can't submit the forms to the right URL as of now. I can do a session thing. Anyone know away to make the back button work on jQuery pages?
  13. So now that I got all pages with links to load in my content area, my next hurdle is the forms. I can't get the code to LMK when a form is being submitted . I can't bind it upon loading page since the forms will be loaded at a later time. So I tried to bind any form that is inside php__container. There's definitely a bunch of people here that seems like they know more about this then me. var jq = $.noConflict(); jq(document).ready(function() { jq("#php__container > form").submit(function(){ alert("form"); e.preventDefault(); }); jq('a').on('click', function(e) { var url = jq(this).attr('href'); if(url.includes("?")) { e.preventDefault(); jq("#php__container").load(url); } }); jq('#php__container').click(function(e){ if (jq(e.target).is('a')) { e.preventDefault(); var url = e.target.href; jq("#php__container").load(url); //alert(url); } }); // update_stats(); });
  14. Lol, thanks. I can't believe I overlooked that.
  15. Aight, I have gotten it to work to some extent. Once my content gets loaded into the php__cointaner div, I can get the link recognized with this new code. I watch it load the new content inside the div, then it redirects :(. So.. preventDefault isn't working properly. var jq = $.noConflict(); jq(document).ready(function() { jq('a').on('click', function(e) { var url = jq(this).attr('href'); if(url.includes("?")) { e.preventDefault(); jq("#php__container").load(url); } }); jq('#php__container').click(function(e){ if (jq(e.target).is('a')) { e.preventDefault; var url = e.target.href; jq("#php__container").load(url); //alert(url); } }); // update_stats(); });
  16. There is no errors in the code what so ever. I click a link, it loads my NEW PAGE WITH LINKS using Ajax. The NEW LINKS that APPEAR on the NEW LOADED content don't load with Ajax. My guess is, the JavaScript code is not binded(terminology?) to the new content loaded? Edit: edited main post to fix vvvv things and removed commented code.
  17. My code spacing is correct before I post it in here. #2 the vvvvvs was correct JS before posted here. It read URL.includes The unnecessary it's will be removed over done texting. BUT most importantly you mentioned everything but anything regarding the question at hand
  18. So I needed to turn every URL on my page into a jQuery/Ajax link (WHICH PARTIALLY WORKS). Every link works except for any new links(ones that get loaded from my Ajax call). So say I load ?page=crimes It will load perfectly in my php__cointainer. But now when the module HTML loads. Say the crimes, yo click the commit button URL ex: ?page=crimes&action=commit&crime=1 The Ajax no longer works. It loads a fresh page. var jq = $.noConflict(); jq(document).ready(function() { jq('a').on('click', function(e) { var url = jq(this).attr('href'); if(url.includes("?")) { e.preventDefault(); alert(url); jq("#php__container").load(url); } else { alert ("no url"); } }); update_stats(); });
  19. VueJS. A JS engine for game?
  20. Sim

    jQuery

    What is the AAAAAA
  21. Sim

    jQuery

    There was no error. Why it had me fooled for a minute. And it was after the jQuery.
  22. Sim

    jQuery

    I don't see why it doesn't load the content. The alert displays the correct URL. So unsure what exactly yo mean HTML: <div class="php__container" id="#php__container"> <div class="tab-pane" id="topnav-tab2" role="tabpanel"> <ul class="php__links nav nav-justified"> <li class="nav-item"><a class="nav-link" href="characters.html">Character</a></li> <li class="nav-item"><a class="nav-link" href="inventory.html">Inventory</a></li> <li class="nav-item"><a class="nav-link" href="battle.html">Battle</a></li> <li class="nav-item"><a class="nav-link" href="upgrade.html">Upgrade</a></li> </ul> </div> JavaScript: $(document).ready(function() { $('.php__links > li > a').click(function(e) { e.preventDefault(); alert($(this).attr('href')); $("#php__container").load($(this).attr('href')); }); }); I got it figured out. I included my JavaScript after my css file 🙂 I included it in the wrong spot somewhere. 🙂
  23. Sim

    jQuery

    What exactly do to mean?
  24. Sim

    jQuery

    Anyone, both issues (this and other post) I have are stopping my development of anything right now?
  25. If I'm not mistaken GL has its own constructor for mods: public $helper = null; public function constructModule() { include "class/ItemHelperFunctions.php"; $this->helper = new ItemHelperFunctions(); $this->method_view(); } Now the issue rises: All my methods I had to include in my helper class $this->getSelectedItem(); becomes $this->helper->getSelectedItem (); But the real issue is on 2 of the 6 mods it doesn't work. $helper remains NULL(doesn't assign). Anyone got a solution? Or know the problem? I even tried using the regular constructor but the problem remains the same on 2 of the 6 mods. It's got me a bit confused. Error: Uncaught Error: Call to a member function getSelectedItem() on null in /home/simmakew/public_html/GL/modules/installed/blackMarket/blackMarket.inc.php:357 Stack trace: #0 Edit: The constructors in any GL module following @Dayoformat is broke. Using the method constructModule is not called first UNLESS ANOTHER METHOD IS NOT CALLED . To fix this issue Open: class/module.PHP Find: if ($this->construct) { $this->constructModule(); } MOVE BEFORE: if (isset($this->methodData->action)) { $methodAction = 'method_'.$this->methodData->action; if (method_exists($this, $methodAction)) { $this->$methodAction(); } } Now I am not %100 sure why function __construct() Does not keep the globals from module PHP. The globals, $page, $db, $user no longer work. $this->page, $this->DB, $this->user By my fix above handles all issues I have mentioned. Error: Uncaught Error: Call to a member function prepare() on null in
×
×
  • Create New...