$ .post with the error "... is not a function"

Here is my code:

var jqxhr = $.post("mypage.php", {url:pageurl}, function() {
      alert("fetching...");
})
.success(function() { alert("fetch complete!"); })
.error(function() { alert("error!"); })
.complete(function() { alert("complete"); });

// Set another completion function for the request above
jqxhr.complete(function(){ alert("second complete"); });

I get an alert dialog box ("Fetching ..."), but the rest of the code does not exit. I get the error message: Error: $ .post ("sec_fetch_report.php", function () {alert ("fetching ...");}). Success is not a function

I thought maybe I might miss the jquery library, but I have another function that calls $ .post, and it works fine. Is there a syntax error that I am missing somewhere or what? Thanks

+3
source share
4 answers

. , , .success $.post(), , , . , $.ajax $.post:

 $.ajax({
     type: 'POST',
     url: 'mypage.php',
     data: { url: pageurl },
     beforeSend: function()
     {
         alert('Fetching....');
     },
     success: function()
     {
         alert('Fetch Complete');
     },
     error: function()
     {
         alert('Error');
     },
     complete: function()
     {
         alert('Complete')
     }
 });
+7

jQuery 1.5+ ( ). , jQuery. , success/error/complete options (, Tejs).

+2

jqxhr v1.5. , .

: jQuery 1.5 ,

+1

. : jQuery.post

​​, jQuery

0

All Articles