0

i want to add a javascript code , which i getting from the server to my view .

is this possible .

i am doing this

 jQuery(".city").change(function(){ var address = jQuery('#business-address').val(); var city = jQuery('.city').val(); var state = jQuery('.state').val(); var country = jQuery('.country').val(); var address_string = address+","+city+","+state+","+country; jQuery.ajax({ type: "post", url: baseurl+"home/auth/create_google_map_from_address", data:{address:address_string}, success: function(data,status){ var data_array = JSON.parse(data); var latitude = data_array['map']['markers']['marker_0'].latitude; var longitude = data_array['map']['markers']['marker_0'].longitude; var map_js = data_array['map'].js; var map_html = data_array['map'].html; alert(latitude); jQuery('#gmap_js').html(map_js); } }); }); 

i am getting a javasript code to variable map_js

i want to add this code to the html page ,

currently i am using jQuery('#gmap_js').html(map_js);

but it is not working , how to do this .

this is map_js

enter image description here

please help...........

1 Answer 1

1

You can do it this way, make you use escape character back slash \ where you need as you will see in the example code.

var map_js = '<script language="javascript" type="text\/javascript"> alert("Js");<\/script>' jQuery('head').append(map_js); 

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.