Jump to content

reload script from ajax


elcaiaimar

Recommended Posts

Hello, I'm trying to reload only a script instead of entire page. And I want to apply it in an ajax script. How could I do that?

 

My web contains a map(script of openlayers) and I put data into the map. So when I remove this data by a button I would like reload only the map.

 

Here is my code. It only shows an alert if the object has been removed or not:

// Autor: @jqcaper// Configuraciones Generalesvar nombre_tabla_pozos = "#tabla_pozos"; // idvar nombre_boton_eliminar_pozo = ".deletepozo"; // Clasevar nombre_formulario_modal_pozo = "#frmEliminarpozo"; //idvar nombre_ventana_modal_pozo = "#pozoModal"; // id// Fin de configuraciones$(document).on('ready',function(){    $(nombre_boton_eliminar_pozo).on('click',function(e){        e.preventDefault();        var Pid_pozo = $(this).attr('id');        var name_pozo = $(this).data('name');        $('#modal_idPozo').val(Pid_pozo);        $('#pozo_name').text(name_pozo);    });    var options_pozo = {        success:function(response)        {                        if(response.status=="True"){                alert("¡Object removed!");                var idPozo = response.pozo_id;                var elementospozo= $(nombre_tabla_pozos+' >tbody >tr').length;                if(elementospozo==1){                    location.reload();                }else{                    $('#tr'+idPozo).remove();                    $(nombre_ventana_modal_pozo).modal('hide');                }            }else{                alert("¡There was an error when remove!");                $(nombre_ventana_modal_pozo).modal('hide');                **RELOAD SCRIPT            };        }    };    $(nombre_formulario_modal_pozo).ajaxForm(options_pozo);});

Thank you very much!

 

 

Link to comment
Share on other sites

Now, I click a button to remove db registers so I don't want to click another button to execute the map script. I think that the best way would be to click in the delete button, then shows an alert saying removed and automatically execute the script. For that, I've thought in execute it from the code above, if it was possible.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...