Click here to Skip to main content
15,905,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<!DOCTYPE html>
<html>
<head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>

    <script>
        $(document).ready(function () {
            $("button").click(function(){
                //$.post("http://localhost/api/ajax.asp",  //This is working
                $.post("http://zequet.somee.com/ajax.asp", // This is not working
        {
          name: "100"
        },
        function(data,status){
            console.log(data);
            document.getElementById("change").innerHTML = data;


            if (data.success) {
                alert("STATUS: " + status);
            }
            else {
                alert("STATUS: " + status);
            }
        });
     });
});
    </script>
</head>
<body>
    Ticket: <span id="change"></span><br />
    <button>Test</button>
</body>
</html>


C#
And this is the ajax.asp code

    <%
        Dim fname
        fname = Request.Form("name")
        fname = fname + 1
        Response.Write(fname)
    %>


What I have tried:

It works fine when using $.post("http://localhost/api/ajax.asp"
but it doesn't work when using $.post("http://zequet.somee.com/ajax.asp" when executing from my local computer.
Posted
Updated 25-Jun-16 23:08pm
Comments
ZurdoDev 25-Jun-16 19:25pm    
why doesn't it work? Debug it and find out.
zequet 25-Jun-16 19:26pm    
How I debug JavaScript??

http://zequet.somee.com/ajax.asp[^]
is not on your localhost. You will get cross domain exception, or something like that, as far as I know. You must send that address to ASP.NET and let ASP.NET get the content and send it back to jquery as a result (probably JSON format) and it works.
 
Share this answer
 
Comments
zequet 25-Jun-16 22:36pm    
Do you have any example? I am not sure how to do all that
zequet asked:
How I debug JavaScript?
By using a JavaScript debugger. Visual Studio can do it, but, to best of my knowledge, it only works with IE (maybe Edge). Chrome browser has a fully functional JavaScript debugger, but by far not so convenient. There is a good number of other projects with JavaScript debuggers; just do your Web search.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900