Click here to Skip to main content
15,884,177 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'll check the value returned by the function if it was one thing and do another task, but it does not work otherwise?
JavaScript
$.post('ajaxs.php', {
      name: name_,
      mail: mail_,
      matn: matn_,
      url: url_,
      id: id_
  },function (data) {
      $('#readmore').html(data);

      if (data == 1) {
          $('#readmore').css({
              "border-color": "#00CC00",
              "border-width": "1px",
              "border-style": "solid"
          });
      } else {
          $('#readmore').css({
              "border-color": "#ff0000",
              "border-width": "1px",
              "border-style": "solid"
          });
      }
});
Posted
Updated 14-Mar-13 11:48am
v2
Comments
Sandeep Mewara 14-Mar-13 9:19am    
Can you rephrase on what are you trying to do and ask here?
Sergey Alexandrovich Kryukov 14-Mar-13 18:10pm    
OP rephrased it, but not clearer then before.
I think I understand the problem, tried to explain things in detail, please see.
—SA
bcsilent 14-Mar-13 9:40am    
Thanks for your attention
I want to send the values ​​to the page
Ajax. PHP
If the operation was successful, and if that was unsuccessful it returns an integer value 0
But now the number 1 Brgrdvndh it's not green Dao Bvrdr Ife does not operate

1 solution

This is not "return", but is HTTP response. Big difference, I'll tell you.

Look at the documentation page, to understand what you are missing:
http://api.jquery.com/jQuery.post/[^].

Don't mix the content of the HTTP response coming from 'ajaxs.php' with success status. The response is passed to your success callback; this is your function object function (data) { /* ... */ }. If processing of data is concerned (you did not use the dataType parameter, which is "Intelligent Guess" by default, not the best option, so I am not sure it returns integer as you expected), check it up under debugger or using some debug code (even simple alert(data)).

Now, if you want to check up if the HTTP request/response failed or not, you don't need to inquire about it. Your purpose is not just knowing it, but doing some processing based on the success status; you don't need the status itself. So, look at the section "The jqXHR Object", where you can see how to provide handlers for .done, .fail and .always cases; look at the code sample. This is the jQuery style imitating a try-catch-finally statement.

Good luck,
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900