Page 1 of 1
jquery $.get() help [SOLVED]
Posted: Sat Mar 01, 2008 10:14 am
by s.dot
Code: Select all
function postAjax(page, threadid)
{
$.get('includes/ajax/forum_showthread.php_numpages.php', function(dt)
{
if (dt == page)
{
//$.post() here
return false;
}
return true;
});
}
What I need this piece of code to do is return true only if the data returned from the $.get() call is not equal to the 'page' var.
However, my browser isn't waiting for the ajax call to complete, and doesn't return anything. How can I get my function to wait on the ajax request to complete before returning?
Re: jquery $.get() help
Posted: Sun Mar 02, 2008 2:11 am
by s.dot
OK, I have it working in firefox.
Code: Select all
function postAjax(page, threadid)
{
var equalTo = (!(cpetsp(page, threadid) == page));
if (!equalTo)
{
$.post('includes/ajax/forum_showthread.php_reply.php', $('#frmPost').serialize(), function(data)
{
document.getElementById('txtPost').value = '';
document.getElementById('myPost').innerHTML = data;
$('#myPost').show('slow');
});
}
return equalTo;
}
function cpetsp(page, threadid)
{
var html = $.ajax({
type: "GET",
url: "includes/ajax/forum_showthread.php_numpages.php",
data: "threadid="+threadid+"&page="+page,
async: false,
}).responseText;
return html;
}
However, it will not work in IE and Opera. I don't know how to get debug info out of IE, but opera tells me..
Inline script compilation
Syntax error while loading: line 27 of inline script at xxxxx :
}).responseText
--------^
Anybody know what this means or how to fix it?
Re: jquery $.get() help
Posted: Sun Mar 02, 2008 2:42 am
by s.dot
OK, had a bogus comma after async: false.
Solved!
Re: jquery $.get() help [SOLVED]
Posted: Sun Mar 02, 2008 10:48 pm
by Kieran Huggins
not sure exactly what you're going for here, but have you looked at
http://jquery.bassistance.de/api-browse ... apFunction ?