2013-11-04 109 views
0

我在我的jquery移动页面上调用插入脚本(untitled.asp)进行数据插入的脚本,但是当我按提交按钮时它告诉我错误加载页面并且它不起作用错误加载页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.min.css" /> 
    <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.min.js"></script> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 
<form action="" method="POST" name="form1" id="form1"> 
    <table width="327" border="0"> 
    <tr> 
     <td width="88">Item</td> 
     <td width="185"><label for="item_name"></label> 
     <input type="text" name="item_name" id="item_name" /></td> 
    </tr> 
    <tr> 
     <td>Quantity</td> 
     <td><label for="quantity"></label> 
     <input type="text" name="quantity" id="quantity" /></td> 
    </tr> 
    <tr> 
     <td>Price</td> 
     <td><label for="price"></label> 
     <input type="text" name="price" id="price" /></td> 
    </tr> 
    <tr> 
     <td colspan="2">&nbsp; 
     <input type="submit" value="Submit" /></td> 
    </tr> 
    </table> 
</form> 



    <script> 
$(document).ready(function(){ 
    $("form").on('submit',function(event){ 
    event.preventDefault(); 

     data = $(this).serialize(); 

     $.ajax({ 
     type: "POST", 
     url: "untitled.asp", 
     data: data 
     }).done(function(msg) { 
     alert("Data Saved: " + msg); 
     }); 
    }); 
}); 
</script> 
</body> 
</html> 

正常工作的网站上,但把当它变成一个移动应用程序它会弹出这个错误 enter image description here

+2

哪个错误?你可以请在控制台窗口发布错误? –

+0

从form标签中删除“action”和“method”。 –

+0

@sujata。怎么样?因为如果我删除它,代码将破坏。 – blay

回答

0

[ValidateAntiForgeryToken]在控制器的ActionResult注解可能会导致“错误加载页面”

[AllowAnonymous] 
    [HttpPost] 
    // [ValidateAntiForgeryToken] this line caused error loading page 
    public ActionResult Submit(Model model) 
    {