SRL Archive - Web Development

how do I send multiple POST 's with this? (ajax)


grats

2013-02-26 21:17:48

$(function()

{

$('.more').live("click",function()

{

var ID = $(this).attr("id");

if(ID)

{

$("#more"+ID).html('<img src="moreajax.gif" />');



$.ajax({

type: "POST",

url: "scripts/file.php",

data: "lastmsg="+ ID,

cache: false,

success: function(html){

$("span#updates").append(html);

$("#more"+ID).remove(); // removing old more button

}

});

}

else

{

$(".morebox").html('The End');// no results

}



return false;

});

});

http://stackoverflow.com/questions/6085649/ajax-multiple-data

I tried everything on that page, nothing works

it sends that lastmsg post fine, that's all I can get it to send though.. I need to send one more..

or a GET, either is fine with me, if someone knows how to do either



nvm I gave up, just sent all data in that one POST and then separated it out with php, rofl.

Bobarkinator

2013-03-01 11:21:17

What do you mean when you say you want to send one more?

sirlaughsalot

2013-03-01 22:02:36


$(function()

{

$('.more').live("click",function() {

var ID = $(this).attr("id");

if(ID)

{

$("#more"+ID).html('<img src="moreajax.gif" />');



$.ajax({

type: "POST",

url: "scripts/file.php",

data: { lastmsg: ID, whatever: someValue },

cache: false,

success: function(html){

$("span#updates").append(html);

$("#more"+ID).remove(); // removing old more button

}

});

}

else

{

$(".morebox").html('The End');// no results

}



return false;

});

});

That syntax should work, what are you trying to get work?

grats

2013-03-01 22:17:28

tried those, not sure why it doesn't work.. I gave up

it needs the +ID because it grabs the ID I think (I am only good at php and database stuff -.- )


anyway I just do

$result = str_getcsv($postid, "p", "'");

$tid = $result[1];

$postidquery = $result[0];


and my POST I send is somenumberpsomenumber

like 123p123

works well, I also sanitize everything except 0-9 and 'p' lol

thanks for help though, not sure what is wrong with all of what everyone says it should be working.. but anything javascript just looks horrid to me so I avoid it as much as possible

sirlaughsalot

2013-03-01 22:27:21

I was more saying the javascript you were trying to get to work. I started in php and javascript was different to get the hang of, especially if you write procedural PHP. It just took a bit of perseverance. Honestly though that is a pretty dumb way to get around it. If you could post the HTML and the javascript you want to work, I may be able to figure out what is wrong.

grats

2013-03-01 22:35:04

That's all it's doing though

<div id="more201303011949081" class="morebox"><a href="#" class="more" id="201303011949081">Load Threads</a></div>

I'd have to take two values out of two ID's instead of just one string that I identify (this one has two variables I take out in it, no need for str_getcsv though)

tbh it's faster the way I'm doing it now, than grabbing two vars and printing out two separate of everything, everytime.. although it may be cool to figure it out


http://www.9lessons.info/2009/12/twitter-style-load-more-results-with.html

I got some of it here, a link I got from my other thread I had a question in.. (well a link I found from the other link)

take note my div is a div, not a span, which is what that ajax calls for.. (because the link I PM'd you has two different places to do this, one uses one, other uses other)