html - jquery AJAX requests -


hallo, new jquery, ajax requests. here html code in edit_page.php

                    <td>action: </td>                                <td class="notselected">                                     <div id="action_response"></div>                                     <select name="action_db1" id=<?php  echo $sel_page['concession']; ?> onchange="updateaction(this);" >                                         <option value=""></option>                                         <option value="move">move</option>                                         <option value="copy">copy</option>                                         <option value="exclude">exclude</option>                                     </select>                                 </td> 

and javascript code is

function updateaction(item) {         $.post("edit_page_advanced_actions.php", {concession:item.id, action:item.value, db_name:item.name},function(action_response) {          $('#action_response').html(action_response);          }); } 

here calling php script *edit_page_advanced_actions.php* in wrote php code. want return messages here based on database updation edit_page.php. i.e calling script.

edit:-

i updating database in edit_page_advanced_actions.php. want return error message or success message edit_page.php. i.e triggered. example "successfully updated", "copied successfully","failed exclude" users based on db operations.

how can accomplished.

thanks in advance!

you should return error status in http header using php header function. example:

header("status: 400 bad request"); echo "the error is: ...."; 

you can use$.ajax special error function:

$.ajax({   type: 'post',   url: "edit_page_advanced_actions.php",    data: {     concession:item.id,      action:item.value,      db_name:item.name   },   succes: function(data, action_response) {      $('#action_response').html(action_response);   },   error: function(xhr, action_response) {      // error code goes here      alert(action_response);   } }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -