Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43261
Total Topics: 7519
Most Online Today: 297
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 287
Total: 287

Author Topic: AJAX to update a row in member's column  (Read 3725 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
AJAX to update a row in member's column
« on: September 22, 2014, 01:38:15 am »
I have a modal that appears for logged in member, and when it appears they must click OK and it goes away for 30 days (as it is currently javascript-based).

I have created a column in the main members table. I want to learn how when you click OK in the modal, the row for that member gets updated to a 1.

I've learned that I can create a function and inside the function add:

Code: [Select]
updateMemberData($ID_MEMBER_POST, array('MODAL_COLUMN' => '1'));
But how do I do this via AJAX instead. I don't want the page to reload if the member clicks OK.




Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: AJAX to update a row in member's column
« Reply #1 on: September 22, 2014, 07:44:17 am »
Ajax is just a remote javascript call.
In ezPortal I kind of use a trick to load a temp image to fake it.
The code below is javascript but you can use it to pass information
Code: [Select]
function EzPortalSaveBlockState(ezBlock,ezState,isBlock)
{
var tempImage = new Image();
if (isBlock == 1)
tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=ezportal;sa=blockstate;blockid=" + ezBlock + ";state=" + ezState + ";sesc=" + "' . $context['session_id'] . '" +  ";" + (new Date().getTime());
else
tempImage.src = smf_scripturl + (smf_scripturl.indexOf("?") == -1 ? "?" : "&") + "action=ezportal;sa=columnstate;columnid=" + ezBlock + ";state=" + ezState + ";sesc=" + "' . $context['session_id'] . '" +  ";" + (new Date().getTime());

}';
Real javascript ajax is something like
Code: [Select]
function looklistfields(listid)
{
var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
       result = xmlhttp.responseText;
       listConditionsText = result;

document.getElementById("conditionfields").innerHTML = '<select name="searchfield">' + result + '</select>';


    }
  }
  var d = new Date();

xmlhttp.open("GET","dolistcondition.php?id=" + listid + "&t=" + d.getTime() ,true);
xmlhttp.send();
}

Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: AJAX to update a row in member's column
« Reply #2 on: September 22, 2014, 12:27:49 pm »
Thanks, SMFHacks. I think AJAX implementation is my Achilles heal.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: AJAX to update a row in member's column
« Reply #3 on: September 22, 2014, 12:39:38 pm »
It's not too bad. You just need a function to send data and get the response then it is pretty much all the same.
They make it sound harder than it is. Is is just remote pulling of information.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: AJAX to update a row in member's column
« Reply #4 on: September 22, 2014, 12:58:10 pm »
By the way, I don't think EzPortal is formatting the blocks on either side correctly! It's making it difficult to maneuver.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16436
    • View Profile
Re: AJAX to update a row in member's column
« Reply #5 on: September 22, 2014, 01:06:33 pm »
Yeah I am looking into the display on this page. It gets way too wide.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

 

Related Topics

  Subject / Started by Replies Last post
8 Replies
8612 Views
Last post March 19, 2007, 02:31:15 pm
by Gourgi
2 Replies
5925 Views
Last post May 25, 2007, 11:35:19 am
by Renegd98
0 Replies
2401 Views
Last post December 15, 2010, 09:07:23 pm
by G1
2 Replies
5483 Views
Last post October 09, 2011, 10:00:42 am
by Gelorto
1 Replies
3179 Views
Last post October 29, 2014, 05:31:28 pm
by SMFHacks

+- Recent Topics

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
Today at 08:27:36 am

No thumbnails on new uploads by Tonyvic
Today at 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Powered by EzPortal