javascript - Form submition using AJAX is not working -


im tring submit form other page using ajax, doesn't send post.

javascript on top of page.

<script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script> $(function(){ $(".button").click(function(){     event.preventdefault();     var name = $("#name").val();     var datavar = "name=" + name;     $.ajax({         type: "post",         url: "https://www.example.ee/index.php?e=area_sa&date=2010",         data: datavar,         success: function() {             alert("works");         }     });   }); }); <script> 

and html code:

<form>     <input type="text" name="name" id="name">     <input type="submit" name="submit" class="button" value="add"> </form> 

it's not working because you're trying make cross-domain ajax request.

if have domain mywebsite.com, ajax requests should limited domain, e.g. mywebsite.com/example/ajax/request.

what you're trying (cross-domain request) possible involves workaround that's bit more complicated, , makes use of different library calls.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -