elcaiaimar Posted April 14, 2015 Share Posted April 14, 2015 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 More sharing options...
justsomeguy Posted April 14, 2015 Share Posted April 14, 2015 "Reload a script" doesn't make much sense. If you want to create the map the same way you did when you set the page up then just run the same code again after removing it. Link to comment Share on other sites More sharing options...
elcaiaimar Posted April 14, 2015 Author Share Posted April 14, 2015 Ok, thanks for your clarification. Just a question, How could I run the script from my code? I've seen that you can do it with events but I dont want to use any button to do it. Thank you again! Link to comment Share on other sites More sharing options...
justsomeguy Posted April 14, 2015 Share Posted April 14, 2015 I've seen that you can do it with events but I dont want to use any button to do it.How do you want to do it then? Link to comment Share on other sites More sharing options...
elcaiaimar Posted April 14, 2015 Author Share Posted April 14, 2015 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 More sharing options...
justsomeguy Posted April 14, 2015 Share Posted April 14, 2015 If you want to run it on the same button click that's fine, there's no limit to how much code you can run at a certain time. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now