Sorry, that function needs to be attached to jQuery object... if
you're just going to put up an alert box, you can use:

$(document).ajaxError(function(request, settings){
     alert('An error has occurred!');
 });

That should work, I think.

- jake

On 2/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> >  -------Original Message-------
> >  From: Jake McGraw <[EMAIL PROTECTED]>
> >  Subject: Re: [jQuery] Why isn't my Ajax call working?
> >  Sent: Feb 16 '07 22:33
> >
> >  Which PHP array are you using to access user variables? If you're
> >  using $_GET, then your AJAX Post variables won't show up in the
> >  application, I usually use $_REQUEST. Also, have you thought of using
> >  the jQuery ajax abstraction methods? Something like this should do the
> >  trick (not tested):
> >
> >  $.ajaxError(function(request, settings){
> >  alert('An error has occurred!');
> >  });
> >
> >  function loadModuleHTML(p_id, p_moduleIndex) {
> >  $.post('get_file_contents.php',{mod_index:p_moduleIndex},function(data){
> >  $("#"+p_id).empty().append('<div class="sortListInner">'+data+'</div>');
> >  });
> >
> >  $(function(){
> >  loadModuleHTML('li0',0);
> >  });
> >
> >  I noticed that you're using some plain Jane JavaScript, like
> >  'getElementById', etc. In case you haven't already, you should check
> >  out all the amazing things jQuery can do besides ajax.
> >
> >  - jake
> >
> >  On 2/16/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >  > Hi,
> >  >
> >  > I'm sure this is really simple, but here is my dilemma.  I'm trying to 
> > make an Ajax call to get some response text.  However, when I make the 
> > call, my "html" variable is coming up empty.  Additionally, my error 
> > function is never invoked.
> >  >
> >  >         function loadModuleHTML(p_id, p_moduleIndex) {
> >  >                 var html = $.ajax({
> >  >                         type: "POST",
> >  >                         url: "get_file_contents.php",
> >  >                         data: "mod_index=" + p_moduleIndex,
> >  >                         dataType: "html",
> >  >                         error: function(req, errorMsg) {
> >  >                                 alert("An error occurred: " + errorMsg);
> >  >                         }
> >  >                 }).responseText;
> >  >                 alert(html);            // This always returns a blank 
> > alert box.
> >  >                 document.getElementById(p_id).innerHTML = "<div 
> > class=\"sortListInner\">" + html + "</div>";
> >  >         }    // loadModuleHTML
> >  >
> >  >         $().ready(function() {
> >  >                 loadModuleHTML('li0', 0);
> >  >         });
> >  >
> >  > If I hard code the URL "mydomain.com/get_file_contents.php?mod_index=0" 
> > into my browser, I get valid HTML returned.  Any ideas what's going on?
> >  >
> >  > Thanks, - Dave
> >  >
> >  > _______________________________________________
> >  > jQuery mailing list
> >  > [email protected]
> >  > http://jquery.com/discuss/
> >  >
> >
>
> Thanks for this info.  Unfortunately, I'm getting a JS error "$.ajaxError is 
> not a function".  My code is below.  Is that the right syntax or do I need to 
> be using a more current version of jQuery?
>
>         $.ajaxError(function(request, settings){
>                 alert('An error has occurred!');
>         });
>
>         function loadModuleHTML(p_id, p_moduleIndex) {
>                 $.post('get_file_contents.php',
>                         {mod_index:p_moduleIndex},
>                         function(data){
>                                 $("#"+p_id).empty().append('<div 
> class="sortListInner">'+data+'</div>');
>                         });
>         }
>
>         $(function(){
>                 loadModuleHTML('li0',0);
>         });
>
> Thanks, - Dave
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to