I need to open a seperate html page from a ajax call. I was using the following code. But it is not working.
$('#cm').blur(function(){
var cmnumber = document.forms['myform']['cm'].value;
$.ajax({
type:'get',
url: "/validatecm/"+cmnumber,
cache:false,
async:false,
data:cmnumber,
success: function(data) {
if ( data == cmnumber)
{ alert ("Its a valid CM")}
else
{ var answer = confirm("Want to create New one")
if(answer)
{
alert("good")
var win=window.open('cm.html',"_self");
with(win.document)
{
open();
write();
close();
}
}
}
}
})
});
I need to open html file "cm.html" on the same page. Any help will be appreciated
Use window.location property:
window.location.href = "cm.html";
Not quite sure what you're going for with open()
, write()
, and close()
, but you should be able to open the page using window.location:
window.location = 'cm.html';
Note that you can assign either a relative or fully qualified path.