JQuery $ .post syntax

I am using phpStorm to edit a file. This code breaks the page:

$("#delete_all_button").click(function(){ var oTT = TableTools.fnGetInstance( 'pickup_list_all' ); var selectedRows = oTT.fnGetSelectedData(); first = selectedRows[0][selectedRows.length-1]; $.post("delete.php", {'claimID': first}, function(data){ console.log(data); }); }); 

In particular, the colon inbetween ClaimID and the first. When I put a reddish underneath the colon, the editor tells me "expected." When I try to load a page, I don't get errors in the console, and the page is just white.

Another important thing that should be noted is that when copying a previously working mail code from another file that has no errors in the code for this file, errors appear.

What could be the problem? Libraries?

I imported jquery with the following line:

 <script type="text/javascript" charset="utf-8" src="js/jquery-1.7.2.min.js"></script> 

Thanks!

+4
source share
2 answers

The jquery.post () data parameter expects a "Map or line that is sent to the server with the request." You can try changing the second parameter to JSON.stringify({'claimID': first}) or wrap it in brackets to make it an array [{'claimID': first}]

0
source

The standard is that you do not use a quote for the property name. Some older browsers may crash because of this.

 $("#delete_all_button").click(function(){ var oTT = TableTools.fnGetInstance( 'pickup_list_all' ); var selectedRows = oTT.fnGetSelectedData(); first = selectedRows[0][selectedRows.length-1]; $.post("delete.php", {claimID: first}, function(data){ console.log(data); }); }); 
0
source

All Articles